Commit 43ef1744 by Ismael

refactor names

parent d577987f
...@@ -84,48 +84,48 @@ void BenchmarkReporter::ComputeBigO( ...@@ -84,48 +84,48 @@ void BenchmarkReporter::ComputeBigO(
Run* big_o, Run* rms) { Run* big_o, Run* rms) {
CHECK(reports.size() >= 2) << "Cannot compute asymptotic complexity for less than 2 reports"; CHECK(reports.size() >= 2) << "Cannot compute asymptotic complexity for less than 2 reports";
// Accumulators. // Accumulators.
std::vector<int> N; std::vector<int> n;
std::vector<double> RealTime; std::vector<double> real_time;
std::vector<double> CpuTime; std::vector<double> cpu_time;
// Populate the accumulators. // Populate the accumulators.
for (const Run& run : reports) { for (const Run& run : reports) {
N.push_back(run.arg1); n.push_back(run.arg1);
RealTime.push_back(run.real_accumulated_time/run.iterations); real_time.push_back(run.real_accumulated_time/run.iterations);
CpuTime.push_back(run.cpu_accumulated_time/run.iterations); cpu_time.push_back(run.cpu_accumulated_time/run.iterations);
} }
LeastSq resultCpu = MinimalLeastSq(N, CpuTime, reports[0].complexity); LeastSq result_cpu = MinimalLeastSq(n, cpu_time, reports[0].complexity);
// resultCpu.complexity is passed as parameter to resultReal because in case // result_cpu.complexity is passed as parameter to result_real because in case
// reports[0].complexity is oAuto, the noise on the measured data could make // reports[0].complexity is oAuto, the noise on the measured data could make
// the best fit function of Cpu and Real differ. In order to solve this, we take // the best fit function of Cpu and Real differ. In order to solve this, we take
// the best fitting function for the Cpu, and apply it to Real data. // the best fitting function for the Cpu, and apply it to Real data.
LeastSq resultReal = MinimalLeastSq(N, RealTime, resultCpu.complexity); LeastSq result_real = MinimalLeastSq(n, real_time, result_cpu.complexity);
std::string benchmark_name = reports[0].benchmark_name.substr(0, reports[0].benchmark_name.find('/')); std::string benchmark_name = reports[0].benchmark_name.substr(0, reports[0].benchmark_name.find('/'));
// Get the data from the accumulator to BenchmarkReporter::Run's. // Get the data from the accumulator to BenchmarkReporter::Run's.
big_o->benchmark_name = benchmark_name + "_BigO"; big_o->benchmark_name = benchmark_name + "_BigO";
big_o->iterations = 0; big_o->iterations = 0;
big_o->real_accumulated_time = resultReal.coef; big_o->real_accumulated_time = result_real.coef;
big_o->cpu_accumulated_time = resultCpu.coef; big_o->cpu_accumulated_time = result_cpu.coef;
big_o->report_big_o = true; big_o->report_big_o = true;
big_o->complexity = resultCpu.complexity; big_o->complexity = result_cpu.complexity;
double multiplier; double multiplier;
const char* timeLabel; const char* time_label;
std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(reports[0].time_unit); std::tie(time_label, multiplier) = GetTimeUnitAndMultiplier(reports[0].time_unit);
// Only add label to mean/stddev if it is same for all runs // Only add label to mean/stddev if it is same for all runs
big_o->report_label = reports[0].report_label; big_o->report_label = reports[0].report_label;
rms->benchmark_name = benchmark_name + "_RMS"; rms->benchmark_name = benchmark_name + "_RMS";
rms->report_label = big_o->report_label; rms->report_label = big_o->report_label;
rms->iterations = 0; rms->iterations = 0;
rms->real_accumulated_time = resultReal.rms / multiplier; rms->real_accumulated_time = result_real.rms / multiplier;
rms->cpu_accumulated_time = resultCpu.rms / multiplier; rms->cpu_accumulated_time = result_cpu.rms / multiplier;
rms->report_rms = true; rms->report_rms = true;
rms->complexity = resultCpu.complexity; rms->complexity = result_cpu.complexity;
} }
std::string BenchmarkReporter::GetBigO(BigO complexity) { std::string BenchmarkReporter::GetBigO(BigO complexity) {
......
...@@ -31,9 +31,9 @@ BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(benchmark::o1); ...@@ -31,9 +31,9 @@ BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(benchmark::o1);
static void BM_Complexity_O_N(benchmark::State& state) { static void BM_Complexity_O_N(benchmark::State& state) {
auto v = ConstructRandomVector(state.range_x()); auto v = ConstructRandomVector(state.range_x());
const int itemNotInVector = state.range_x()*2; // Test worst case scenario (item not in vector) const int item_not_in_vector = state.range_x()*2; // Test worst case scenario (item not in vector)
while (state.KeepRunning()) { while (state.KeepRunning()) {
benchmark::DoNotOptimize(std::find(v.begin(), v.end(), itemNotInVector)); benchmark::DoNotOptimize(std::find(v.begin(), v.end(), item_not_in_vector));
} }
} }
BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::oN); BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::oN);
...@@ -71,9 +71,9 @@ BENCHMARK(BM_Complexity_O_N_Cubed) -> DenseRange(1, 8) -> Complexity(benchmark:: ...@@ -71,9 +71,9 @@ BENCHMARK(BM_Complexity_O_N_Cubed) -> DenseRange(1, 8) -> Complexity(benchmark::
static void BM_Complexity_O_log_N(benchmark::State& state) { static void BM_Complexity_O_log_N(benchmark::State& state) {
auto m = ConstructRandomMap(state.range_x()); auto m = ConstructRandomMap(state.range_x());
const int itemNotInVector = state.range_x()*2; // Test worst case scenario (item not in vector) const int item_not_in_vector = state.range_x()*2; // Test worst case scenario (item not in vector)
while (state.KeepRunning()) { while (state.KeepRunning()) {
benchmark::DoNotOptimize(m.find(itemNotInVector)); benchmark::DoNotOptimize(m.find(item_not_in_vector));
} }
} }
BENCHMARK(BM_Complexity_O_log_N) BENCHMARK(BM_Complexity_O_log_N)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment