예제 #1
0
/**
   Runs a benchmark.

   It runs it a couple of times just to warm everything up, and then
   does num_trials iterations of the benchmark for time.
 */
void SimpleBenchmarkRunner::run(Benchmark &bench) {
	bench.setup();

	// Warm up.
	bench.run_iteration();
	bench.run_iteration();
	bench.finish_iteration();

	// okay, now for time.
	uint64_t start1 = nanotime();
	for(int i = 0; i < mNumTrials; ++i) {
		bench.finish_iteration();
	}
	uint64_t stop1 = nanotime();

	uint64_t start2 = nanotime();
	for(int i = 0; i < mNumTrials; ++i) {
		bench.run_iteration();
		bench.finish_iteration();
	}
	uint64_t stop2 = nanotime();

	mTotalTime = (stop2 - start2) - (stop1 - start1);
	
	bench.cleanup();
}
예제 #2
0
void AdvancedBenchmarkRunner::run(Benchmark &bench) {
    mTrials.clear();
	bench.setup();

	// Warm up.
	bench.run_iteration();
	bench.run_iteration();
	bench.finish_iteration();

	// okay, now for time.
	for(int i = 0; i < mNumTrials; ++i) {
        auto start = nanotime();
		bench.run_iteration();
        auto stop = nanotime();
		bench.finish_iteration();

        mTrials.push_back(stop - start);
	}
	
	bench.cleanup();
}