From 43ef17441cc8767f5523031878a2f43ab1d7790b Mon Sep 17 00:00:00 2001 From: Ismael Date: Mon, 23 May 2016 20:50:35 +0200 Subject: [PATCH] refactor names --- src/reporter.cc | 34 +++++++++++++++++----------------- test/complexity_test.cc | 8 ++++---- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/reporter.cc b/src/reporter.cc index 0e1c581e..0c05ab0b 100644 --- a/src/reporter.cc +++ b/src/reporter.cc @@ -84,48 +84,48 @@ void BenchmarkReporter::ComputeBigO( Run* big_o, Run* rms) { CHECK(reports.size() >= 2) << "Cannot compute asymptotic complexity for less than 2 reports"; // Accumulators. - std::vector N; - std::vector RealTime; - std::vector CpuTime; + std::vector n; + std::vector real_time; + std::vector cpu_time; // Populate the accumulators. for (const Run& run : reports) { - N.push_back(run.arg1); - RealTime.push_back(run.real_accumulated_time/run.iterations); - CpuTime.push_back(run.cpu_accumulated_time/run.iterations); + n.push_back(run.arg1); + real_time.push_back(run.real_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 // 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. - 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('/')); // Get the data from the accumulator to BenchmarkReporter::Run's. big_o->benchmark_name = benchmark_name + "_BigO"; big_o->iterations = 0; - big_o->real_accumulated_time = resultReal.coef; - big_o->cpu_accumulated_time = resultCpu.coef; + big_o->real_accumulated_time = result_real.coef; + big_o->cpu_accumulated_time = result_cpu.coef; big_o->report_big_o = true; - big_o->complexity = resultCpu.complexity; + big_o->complexity = result_cpu.complexity; double multiplier; - const char* timeLabel; - std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(reports[0].time_unit); + const char* time_label; + std::tie(time_label, multiplier) = GetTimeUnitAndMultiplier(reports[0].time_unit); // Only add label to mean/stddev if it is same for all runs big_o->report_label = reports[0].report_label; rms->benchmark_name = benchmark_name + "_RMS"; rms->report_label = big_o->report_label; rms->iterations = 0; - rms->real_accumulated_time = resultReal.rms / multiplier; - rms->cpu_accumulated_time = resultCpu.rms / multiplier; + rms->real_accumulated_time = result_real.rms / multiplier; + rms->cpu_accumulated_time = result_cpu.rms / multiplier; rms->report_rms = true; - rms->complexity = resultCpu.complexity; + rms->complexity = result_cpu.complexity; } std::string BenchmarkReporter::GetBigO(BigO complexity) { diff --git a/test/complexity_test.cc b/test/complexity_test.cc index e81742ee..e169ad96 100644 --- a/test/complexity_test.cc +++ b/test/complexity_test.cc @@ -31,9 +31,9 @@ BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(benchmark::o1); static void BM_Complexity_O_N(benchmark::State& state) { 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()) { - 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); @@ -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) { 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()) { - benchmark::DoNotOptimize(m.find(itemNotInVector)); + benchmark::DoNotOptimize(m.find(item_not_in_vector)); } } BENCHMARK(BM_Complexity_O_log_N)