当前位置: 首页>>代码示例>>C++>>正文


C++ Stats::clear方法代码示例

本文整理汇总了C++中Stats::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Stats::clear方法的具体用法?C++ Stats::clear怎么用?C++ Stats::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stats的用法示例。


在下文中一共展示了Stats::clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: report

    void report(Stats & info)
    {
        std::lock_guard<std::mutex> lock(mutex);

        /// Avoid zeros, nans or exceptions
        if (0 == info.queries)
            return;

        double seconds = info.watch.elapsedSeconds();

        std::cerr
            << "\n"
            << "QPS: " << (info.queries / seconds) << ", "
            << "RPS: " << (info.read_rows / seconds) << ", "
            << "MiB/s: " << (info.read_bytes / seconds / 1048576) << ", "
            << "result RPS: " << (info.result_rows / seconds) << ", "
            << "result MiB/s: " << (info.result_bytes / seconds / 1048576) << "."
            << "\n";

        auto print_percentile = [&](double percent)
        {
            std::cerr << percent << "%\t" << info.sampler.quantileInterpolated(percent / 100.0) << " sec." << std::endl;
        };

        for (int percent = 0; percent <= 90; percent += 10)
            print_percentile(percent);

        print_percentile(95);
        print_percentile(99);
        print_percentile(99.9);
        print_percentile(99.99);

        info.clear();
    }
开发者ID:yurial,项目名称:ClickHouse,代码行数:34,代码来源:Benchmark.cpp

示例2: test_stats2

void test_stats2() {
    // Test singleton pattern
    Stats* stats = Stats::getUniqueInstance();
    assert(stats->get((StatsKey)4) == 2);

    // Test clear()
    stats->clear();
    assert(stats->get((StatsKey)4) == 0);
}
开发者ID:thabz,项目名称:RayGay,代码行数:9,代码来源:teststats.cpp

示例3: test_stats

void test_stats() {
    Stats* stats = Stats::getUniqueInstance();
    stats->clear();
    // Test Stats::put and get
    stats->put((StatsKey)1,10);
    stats->put((StatsKey)2,20);
    stats->put((StatsKey)3,30);
    assert(stats->get((StatsKey)1) == 10);
    assert(stats->get((StatsKey)2) == 20);
    assert(stats->get((StatsKey)3) == 30);
    stats->inc((StatsKey)1);
    assert(stats->get((StatsKey)1) == 11);

    assert(stats->get((StatsKey)4) == 0);

    // Test Stats::inc
    stats->inc((StatsKey)4);
    assert(stats->get((StatsKey)4) == 1);
    stats->inc((StatsKey)4);
    assert(stats->get((StatsKey)4) == 2);
    //stats->dump();

}
开发者ID:thabz,项目名称:RayGay,代码行数:23,代码来源:teststats.cpp

示例4: calculateStatsDeme

void StatsCalcFitnessNMSEOp::calculateStatsDeme(Stats &outStats, Deme &ioDeme, Context &ioContext) const {
    Beagle_StackTraceBeginM();
    outStats.clear();
    outStats.clearItems();
    int outputs = mConfig->getOutputs().size();
    outStats.addItem("processed", ioContext.getProcessedDeme());
    outStats.addItem("total-processed", ioContext.getTotalProcessedDeme());

    if(ioDeme.size() == 0) {
        outStats.setGenerationValues(Beagle::string("deme")+uint2str(ioContext.getDemeIndex()+1),
                                     ioContext.getGeneration(), 0, true);
        outStats.resize(3+outputs*2);
        outStats[0].mId  = "NMSE";
        outStats[0].mAvg = 0.0;
        outStats[0].mStd = 0.0;
        outStats[0].mMax = 0.0;
        outStats[0].mMin = 0.0;

        outStats[1].mId = "treedepth";
        outStats[1].mAvg = 0.0;
        outStats[1].mStd = 0.0;
        outStats[1].mMax = 0.0;
        outStats[1].mMin = 0.0;

        outStats[2].mId = "treesize";
        outStats[2].mAvg = 0.0;
        outStats[2].mStd = 0.0;
        outStats[2].mMax = 0.0;
        outStats[2].mMin = 0.0;

        for(int i=0; i<outputs; ++i) {
            int nr = 3 + i*2;
            outStats[nr].mId = "y" + int2str(i) + "-NMSE";
            outStats[nr].mAvg = 0.0;
            outStats[nr].mStd = 0.0;
            outStats[nr].mMax = 0.0;
            outStats[nr].mMin = 0.0;
            ++nr;
            outStats[nr].mId = "y" + int2str(i) + "-MSE";
            outStats[nr].mAvg = 0.0;
            outStats[nr].mStd = 0.0;
            outStats[nr].mMax = 0.0;
            outStats[nr].mMin = 0.0;
        }

        return;
    }

    const GP::Deme& gpDeme = castObjectT<const GP::Deme&>(ioDeme);
    const FitnessNMSE::Handle firstIndivFitness = castHandleT<FitnessNMSE>(ioDeme[0]->getFitness());


    if(ioDeme.size() == 1) {
        outStats.setGenerationValues(Beagle::string("deme")+uint2str(ioContext.getDemeIndex()+1),
                                     ioContext.getGeneration(), 1, true);

        outStats.resize(3+outputs*2);
        outStats[0].mId  = "NMSE";
        outStats[0].mAvg = firstIndivFitness->getNMSE();
        outStats[0].mStd = 0.0;
        outStats[0].mMax = firstIndivFitness->getNMSE();
        outStats[0].mMin = firstIndivFitness->getNMSE();

        outStats[1].mId = "treedepth";
        outStats[1].mAvg = gpDeme[0]->getMaxTreeDepth();
        outStats[1].mStd = 0.0;
        outStats[1].mMax = outStats[1].mAvg;
        outStats[1].mMin = outStats[1].mAvg;

        outStats[2].mId = "treesize";
        outStats[2].mAvg = gpDeme[0]->getTotalNodes();
        outStats[2].mStd = 0.0;
        outStats[2].mMax = outStats[2].mAvg;
        outStats[2].mMin = outStats[2].mAvg;

        for(int i=0; i<outputs; ++i) {
            int nr = 3 + i*2;
            double nmse = (*firstIndivFitness)[i].nmse;
            double mse = (*firstIndivFitness)[i].mse;
            outStats[nr].mId = "y" + int2str(i) + "-NMSE";
            outStats[nr].mAvg = nmse;
            outStats[nr].mStd = 0.0;
            outStats[nr].mMax = nmse;
            outStats[nr].mMin = nmse;
            ++nr;
            outStats[nr].mId = "y" + int2str(i) + "-MSE";
            outStats[nr].mAvg = mse;
            outStats[nr].mStd = 0.0;
            outStats[nr].mMax = mse;
            outStats[nr].mMin = mse;
        }
        return;
    }

    double sum = firstIndivFitness->getNMSE();
    double pow2sum = pow2Of<double>(sum);
    double max = sum;
    double min = sum;

    std::vector<double> sumNMSE(outputs, 0);
//.........这里部分代码省略.........
开发者ID:gametack,项目名称:SinsGP,代码行数:101,代码来源:StatsCalcFitnessNMSEOp.cpp

示例5: calculateStatsVivarium

/*!
 *  \brief  Calculate statistics of a given vivarium.
 *  \param  outStats Computed stats of the deme.
 *  \param  ioVivarium Vivarium to evaluate the statistics.
 *  \param  ioContext Context of the evolution.
 */
void StatsCalculateOp::calculateStatsVivarium(Stats& outStats,
        Vivarium& ioVivarium,
        Context& ioContext) const
{
	Beagle_StackTraceBeginM();
	outStats.clear();
	outStats.clearItems();

	unsigned int lPopSize = 0;
	for(unsigned int i=0; i<ioVivarium.size(); ++i) {
		Beagle::Stats::Handle lDemeStats = ioVivarium[i]->getStats();
		Beagle_NonNullPointerAssertM(lDemeStats);
		lPopSize += lDemeStats->getPopSize();
	}
	outStats.setGenerationValues("vivarium", ioContext.getGeneration(), lPopSize, true);
	outStats.addItem("processed", ioContext.getProcessedVivarium());
	outStats.addItem("total-processed", ioContext.getTotalProcessedVivarium());

	if(ioVivarium.size() == 0) return;

	outStats.resize(ioVivarium[0]->getStats()->size());
	for(unsigned int i=0; i<outStats.size(); ++i) {
		double lSumXi     = 0.0;
		double lSumXiPow2 = 0.0;
		double lMax       = (*ioVivarium[0]->getStats())[i].mMax;
		double lMin       = (*ioVivarium[0]->getStats())[i].mMin;

		for(unsigned int j=0; j<ioVivarium.size(); ++j) {
			Beagle_AssertM(outStats.size() == ioVivarium[j]->getStats()->size());
			const Measure& lMeasure  = (*ioVivarium[j]->getStats())[i];
			unsigned int   lDemeSize = ioVivarium[j]->getStats()->getPopSize();
			if(lDemeSize != 0) {
				double lSumFit  =  lMeasure.mAvg * lDemeSize;
				double lTmpVar1 =  pow2Of<double>(lSumFit) / lDemeSize;
				double lTmpVar2 =  pow2Of<double>(lMeasure.mStd) * (lDemeSize-1);
				lSumXi          += lSumFit;
				lSumXiPow2      += lTmpVar1 + lTmpVar2;
				lMax            =  maxOf<double>(lMax, lMeasure.mMax);
				lMin            =  minOf<double>(lMin, lMeasure.mMin);
			}
		}

		outStats[i].mID  = (*ioVivarium[0]->getStats())[i].mID;
		if(lPopSize == 0) {
			outStats[i].mAvg = 0.0;
			outStats[i].mStd = 0.0;
			outStats[i].mMax = 0.0;
			outStats[i].mMin = 0.0;
		} else if(lPopSize == 1) {
			outStats[i].mAvg = lSumXi;
			outStats[i].mStd = 0.0;
			outStats[i].mMax = lMax;
			outStats[i].mMin = lMin;
		} else {
			double lAverage  = lSumXi / lPopSize;
			double lVariance =
			    lSumXiPow2 - (pow2Of<double>(lAverage*((double)lPopSize)) / ((double)lPopSize));
			double lStdError = sqrt(lVariance / (lPopSize - 1));
			outStats[i].mAvg = lAverage;
			outStats[i].mStd = lStdError;
			outStats[i].mMax = lMax;
			outStats[i].mMin = lMin;
		}
	}
	Beagle_StackTraceEndM("void StatsCalculateOp::calculateStatsVivarium(Stats& outStats, Vivarium& ioVivarium, Context& ioContext) const");
}
开发者ID:splodginald,项目名称:MPI-PACC-OpenBeagle,代码行数:72,代码来源:StatsCalculateOp.cpp

示例6: render

	void render(/*double currentTime*/)
	{
		currentTime += time_offset;


		static const GLfloat color[] = { 0.0f, 0.0f, 0.0f, 0.0f };

		float r = 0.0f;

		float t = (float)currentTime;

		r = t + time_offset;

		glm::vec2 C(
				(sinf(r * 0.1f) + cosf(r * 0.53f)) * 2.5f,
				(cosf(r * 0.13f) + sinf(r * 0.21f)) * 0.5f
			   );


		i++;
		if((i % 100) == 0) {

			if(1) {
				int total = 0;
				int count = 0;
				int it_max = -1;
				int it_min = max_iterations + 1;
				int skip = 10;
				float a;
				float log_a_min = FLT_MAX;
				float log_a_max = FLT_MIN;

				stat_a.clear();

				for(int px = 0; px < iscreen.x; px+=skip) {
					for(int py = 0; py < iscreen.y; py+=skip) {
						if(debug) {
							if((count%10)==0) {
								printf("%6s%6s%12s%12s%12s%12s%12s%6s%12s%12s%12s\n", 
										"px", "py",
										"zoom",
										"f", "f",
										"x", "y",
										"it",
										"a",
										"log(a)",
										"a0");
							}}

						int it = solve(glm::ivec2(px,py), C, a);

						count++;
						total += it;
						if(it > it_max) it_max = it;
						if(it < it_min) it_min = it;

						//printf("%f\n",a);
						stat_a.push(a);
						//printf("%f\n",a);
						if(isinf(a)) {
							stat_log_a.push((float)FLT_MAX_EXP);
						} else {
							stat_log_a.push(log(a));
						}
					}
				}

				log_a_min = stat_log_a.min();
				log_a_max = stat_log_a.max();
				if(isinf(log_a_max)) {
					printf("inf log %f\n", (float)FLT_MAX_EXP);
					log_a_max = FLT_MAX_EXP;
				}

				printf("%8s%8s%8s%8s%8s%12s%12s%12s%12s%12s%12s\n",
						"count",
						"total",
						"avg",
						"it_min",
						"it_max",
						"a_min",
						"a_max",
						"log a_min",
						"log a_max",
						"avg log_a",
						"std log_a"
				      );
				printf("%8i%8i%8.2f%8i%8i%12.2e%12.2e%12.2e%12.2e%12.2e%12.2e\n",
						count,
						total,
						(float)total/(float)count,
						it_min,
						it_max,
						stat_a.min(),
						stat_a.max(),
						log_a_min,
						log_a_max,
						stat_log_a.avg(),
						stat_log_a.std());
			}
//.........这里部分代码省略.........
开发者ID:chuck1,项目名称:c-testing,代码行数:101,代码来源:main.cpp


注:本文中的Stats::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。