Skip to content

Commit 9a2d246

Browse files
committed
change the default to not scale
1 parent 0d52a11 commit 9a2d246

8 files changed

+65
-122
lines changed

src/benchmark_runner.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,8 @@ BenchmarkRunner::IterationResults BenchmarkRunner::DoNIterations() {
292292
// And get rid of the manager.
293293
manager.reset();
294294

295-
// Adjust real/manual time stats since they were reported per thread.
296-
i.results.real_time_used /= b.threads();
297-
i.results.manual_time_used /= b.threads();
298-
// If we were measuring whole-process CPU usage, adjust the CPU time too.
299-
if (b.measure_process_cpu_time()) i.results.cpu_time_used /= b.threads();
295+
i.results.real_time_used;
296+
i.results.manual_time_used;
300297

301298
BM_VLOG(2) << "Ran in " << i.results.cpu_time_used << "/"
302299
<< i.results.real_time_used << "\n";

src/console_reporter.cc

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ bool ConsoleReporter::ReportContext(const Context& context) {
6060
BENCHMARK_EXPORT
6161
void ConsoleReporter::PrintHeader(const Run& run) {
6262
std::string str = FormatString(
63-
"%-*s %13s %15s %15s %12s", static_cast<int>(name_field_width_),
64-
"Benchmark", "Time", "Per-Thread Time", "CPU", "Iterations");
63+
"%-*s %13s %15s %12s", static_cast<int>(name_field_width_),
64+
"Benchmark", "Time", "CPU", "Iterations");
6565
if (!run.counters.empty()) {
6666
if (output_options_ & OO_Tabular) {
6767
for (auto const& c : run.counters) {
@@ -151,32 +151,27 @@ void ConsoleReporter::PrintRunData(const Run& result) {
151151
}
152152

153153
const double real_time = result.GetAdjustedRealTime();
154-
const double per_thread_real_time =
155-
real_time * static_cast<double>(result.threads);
156154
const double cpu_time = result.GetAdjustedCPUTime();
157155
const std::string real_time_str = FormatTime(real_time);
158-
const std::string per_thread_real_time_str = FormatTime(per_thread_real_time);
159156
const std::string cpu_time_str = FormatTime(cpu_time);
160157

161158
if (result.report_big_o) {
162159
std::string big_o = GetBigOString(result.complexity);
163-
printer(Out, COLOR_YELLOW, "%10.2f %-4s %10.2f %-4s %10.2f %-4s ",
164-
real_time, big_o.c_str(), per_thread_real_time, big_o.c_str(),
165-
cpu_time, big_o.c_str());
160+
printer(Out, COLOR_YELLOW, "%10.2f %-4s %10.2f %-4s ",
161+
real_time, big_o.c_str(), cpu_time, big_o.c_str());
166162
} else if (result.report_rms) {
167-
printer(Out, COLOR_YELLOW, "%10.0f %-4s %10.0f %-4s %10.0f %-4s ",
168-
real_time * 100, "%", per_thread_real_time * 100, "%",
169-
cpu_time * 100, "%");
163+
printer(Out, COLOR_YELLOW, "%10.0f %-4s %10.0f %-4s ",
164+
real_time * 100, "%", "%", cpu_time * 100, "%");
170165
} else if (result.run_type != Run::RT_Aggregate ||
171166
result.aggregate_unit == StatisticUnit::kTime) {
172167
const char* timeLabel = GetTimeUnitString(result.time_unit);
173-
printer(Out, COLOR_YELLOW, "%s %-4s %s %-4s %s %-4s ",
174-
real_time_str.c_str(), timeLabel, per_thread_real_time_str.c_str(),
175-
timeLabel, cpu_time_str.c_str(), timeLabel);
168+
printer(Out, COLOR_YELLOW, "%s %-4s %s %-4s ",
169+
real_time_str.c_str(), timeLabel,
170+
cpu_time_str.c_str(), timeLabel);
176171
} else {
177172
assert(result.aggregate_unit == StatisticUnit::kPercentage);
178-
printer(Out, COLOR_YELLOW, "%10.2f %-4s %10s %-4s %10.2f %-4s ",
179-
(100. * result.real_accumulated_time), "%", " ", " ",
173+
printer(Out, COLOR_YELLOW, "%10.2f %-4s %10.2f %-4s ",
174+
(100. * result.real_accumulated_time), "%",
180175
(100. * result.cpu_accumulated_time), "%");
181176
}
182177

src/json_reporter.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,25 +274,11 @@ void JSONReporter::PrintRunData(Run const& run) {
274274
run.aggregate_unit == StatisticUnit::kTime) {
275275
out << indent << FormatKV("real_time", run.GetAdjustedRealTime())
276276
<< ",\n";
277-
if (run.threads != 1) {
278-
out << indent
279-
<< FormatKV(
280-
"per_thread_real_time",
281-
run.GetAdjustedRealTime() * static_cast<double>(run.threads))
282-
<< ",\n";
283-
}
284277
out << indent << FormatKV("cpu_time", run.GetAdjustedCPUTime());
285278
} else {
286279
assert(run.aggregate_unit == StatisticUnit::kPercentage);
287280
out << indent << FormatKV("real_time", run.real_accumulated_time)
288281
<< ",\n";
289-
if (run.threads != 1) {
290-
out << indent
291-
<< FormatKV(
292-
"per_thread_real_time",
293-
run.real_accumulated_time * static_cast<double>(run.threads))
294-
<< ",\n";
295-
}
296282
out << indent << FormatKV("cpu_time", run.cpu_accumulated_time);
297283
}
298284
out << ",\n"

test/complexity_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ int AddComplexityTest(const std::string &test_name,
2525
{"%rms", "[ ]*[0-9]+ %"}});
2626
AddCases(
2727
TC_ConsoleOut,
28-
{{"^%bigo_name %bigo_str %bigo_str %bigo_str[ ]*$"},
28+
{{"^%bigo_name %bigo_str %bigo_str[ ]*$"},
2929
{"^%bigo_name", MR_Not}, // Assert we we didn't only matched a name.
30-
{"^%rms_name %rms %rms %rms[ ]*$", MR_Next}});
30+
{"^%rms_name %rms %rms[ ]*$", MR_Next}});
3131
AddCases(
3232
TC_JSONOut,
3333
{{"\"name\": \"%bigo_name\",$"},

test/output_test_helper.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ SubMap& GetSubstitutions() {
5050
{"%int", "[ ]*[0-9]+"},
5151
{" %s ", "[ ]+"},
5252
{"%time", "[ ]*" + time_re + "[ ]+ns"},
53-
{"%console_report", "[ ]*" + time_re + "[ ]+ns [ ]*" + time_re + "[ ]+ns [ ]*" + time_re + "[ ]+ns [ ]*[0-9]+"},
53+
{"%console_report", "[ ]*" + time_re + "[ ]+ns [ ]*" + time_re + "[ ]+ns [ ]*[0-9]+"},
5454
{"%console_percentage_report", "[ ]*" + percentage_re + "[ ]+% [ ]*" + percentage_re + "[ ]+% [ ]*[0-9]+"},
55-
{"%console_us_report", "[ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*[0-9]+"},
56-
{"%console_ms_report", "[ ]*" + time_re + "[ ]+ms [ ]*" + time_re + "[ ]+ms [ ]*" + time_re + "[ ]+ms [ ]*[0-9]+"},
57-
{"%console_s_report", "[ ]*" + time_re + "[ ]+s [ ]*" + time_re + "[ ]+s [ ]*" + time_re + "[ ]+s [ ]*[0-9]+"},
58-
{"%console_time_only_report", "[ ]*" + time_re + "[ ]+ns [ ]*" + time_re + "[ ]+ns [ ]*" + time_re + "[ ]+ns"},
59-
{"%console_us_report", "[ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*[0-9]+"},
60-
{"%console_us_time_only_report", "[ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us"},
55+
{"%console_us_report", "[ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*[0-9]+"},
56+
{"%console_ms_report", "[ ]*" + time_re + "[ ]+ms [ ]*" + time_re + "[ ]+ms [ ]*[0-9]+"},
57+
{"%console_s_report", "[ ]*" + time_re + "[ ]+s [ ]*" + time_re + "[ ]+s [ ]*[0-9]+"},
58+
{"%console_time_only_report", "[ ]*" + time_re + "[ ]+ns [ ]*" + time_re + "[ ]+ns"},
59+
{"%console_us_report", "[ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us [ ]*[0-9]+"},
60+
{"%console_us_time_only_report", "[ ]*" + time_re + "[ ]+us [ ]*" + time_re + "[ ]+us"},
6161
{"%csv_header",
6262
"name,iterations,real_time,cpu_time,time_unit,bytes_per_second,"
6363
"items_per_second,label,error_occurred,error_message"},

test/reporter_output_test.cc

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
// ---------------------- Testing Prologue Output -------------------------- //
1111
// ========================================================================= //
1212

13-
ADD_CASES(TC_ConsoleOut,
14-
{{"^[-]+$", MR_Next},
15-
{"^Benchmark %s Time %s Per-Thread Time %s CPU %s Iterations$",
16-
MR_Next},
17-
{"^[-]+$", MR_Next}});
13+
ADD_CASES(TC_ConsoleOut, {{"^[-]+$", MR_Next},
14+
{"^Benchmark %s Time %s CPU %s Iterations$", MR_Next},
15+
{"^[-]+$", MR_Next}});
1816
static int AddContextCases() {
1917
AddCases(TC_ConsoleErr,
2018
{
@@ -419,9 +417,8 @@ void BM_Complexity_O1(benchmark::State& state) {
419417
BENCHMARK(BM_Complexity_O1)->Range(1, 1 << 18)->Complexity(benchmark::o1);
420418
SET_SUBSTITUTIONS({{"%bigOStr", "[ ]* %float \\([0-9]+\\)"},
421419
{"%RMS", "[ ]*[0-9]+ %"}});
422-
ADD_CASES(TC_ConsoleOut,
423-
{{"^BM_Complexity_O1_BigO %bigOStr %bigOStr %bigOStr[ ]*$"},
424-
{"^BM_Complexity_O1_RMS %RMS %RMS %RMS[ ]*$"}});
420+
ADD_CASES(TC_ConsoleOut, {{"^BM_Complexity_O1_BigO %bigOStr %bigOStr[ ]*$"},
421+
{"^BM_Complexity_O1_RMS %RMS %RMS[ ]*$"}});
425422

426423
// ========================================================================= //
427424
// ----------------------- Testing Aggregate Output ------------------------ //
@@ -439,8 +436,7 @@ ADD_CASES(TC_ConsoleOut,
439436
{"^BM_Repeat/repeats:2 %console_report$"},
440437
{"^BM_Repeat/repeats:2_mean %console_time_only_report [ ]*2$"},
441438
{"^BM_Repeat/repeats:2_median %console_time_only_report [ ]*2$"},
442-
{"^BM_Repeat/repeats:2_stddev %console_time_only_report [ ]*2$"},
443-
{"^BM_Repeat/repeats:2_cv %console_percentage_report[ ]*$"}});
439+
{"^BM_Repeat/repeats:2_stddev %console_time_only_report [ ]*2$"}});
444440
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Repeat/repeats:2\",$"},
445441
{"\"family_index\": 15,$", MR_Next},
446442
{"\"per_family_instance_index\": 0,$", MR_Next},
@@ -500,8 +496,7 @@ ADD_CASES(TC_ConsoleOut,
500496
{"^BM_Repeat/repeats:3 %console_report$"},
501497
{"^BM_Repeat/repeats:3_mean %console_time_only_report [ ]*3$"},
502498
{"^BM_Repeat/repeats:3_median %console_time_only_report [ ]*3$"},
503-
{"^BM_Repeat/repeats:3_stddev %console_time_only_report [ ]*3$"},
504-
{"^BM_Repeat/repeats:3_cv %console_percentage_report[ ]*$"}});
499+
{"^BM_Repeat/repeats:3_stddev %console_time_only_report [ ]*3$"}});
505500
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Repeat/repeats:3\",$"},
506501
{"\"family_index\": 16,$", MR_Next},
507502
{"\"per_family_instance_index\": 0,$", MR_Next},
@@ -571,8 +566,7 @@ ADD_CASES(TC_ConsoleOut,
571566
{"^BM_Repeat/repeats:4 %console_report$"},
572567
{"^BM_Repeat/repeats:4_mean %console_time_only_report [ ]*4$"},
573568
{"^BM_Repeat/repeats:4_median %console_time_only_report [ ]*4$"},
574-
{"^BM_Repeat/repeats:4_stddev %console_time_only_report [ ]*4$"},
575-
{"^BM_Repeat/repeats:4_cv %console_percentage_report[ ]*$"}});
569+
{"^BM_Repeat/repeats:4_stddev %console_time_only_report [ ]*4$"}});
576570
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Repeat/repeats:4\",$"},
577571
{"\"family_index\": 17,$", MR_Next},
578572
{"\"per_family_instance_index\": 0,$", MR_Next},
@@ -672,8 +666,7 @@ ADD_CASES(
672666
{{".*BM_SummaryRepeat/repeats:3 ", MR_Not},
673667
{"^BM_SummaryRepeat/repeats:3_mean %console_time_only_report [ ]*3$"},
674668
{"^BM_SummaryRepeat/repeats:3_median %console_time_only_report [ ]*3$"},
675-
{"^BM_SummaryRepeat/repeats:3_stddev %console_time_only_report [ ]*3$"},
676-
{"^BM_SummaryRepeat/repeats:3_cv %console_percentage_report[ ]*$"}});
669+
{"^BM_SummaryRepeat/repeats:3_stddev %console_time_only_report [ ]*3$"}});
677670
ADD_CASES(TC_JSONOut,
678671
{{".*BM_SummaryRepeat/repeats:3 ", MR_Not},
679672
{"\"name\": \"BM_SummaryRepeat/repeats:3_mean\",$"},
@@ -724,8 +717,7 @@ ADD_CASES(
724717
{{".*BM_SummaryDisplay/repeats:2 ", MR_Not},
725718
{"^BM_SummaryDisplay/repeats:2_mean %console_time_only_report [ ]*2$"},
726719
{"^BM_SummaryDisplay/repeats:2_median %console_time_only_report [ ]*2$"},
727-
{"^BM_SummaryDisplay/repeats:2_stddev %console_time_only_report [ ]*2$"},
728-
{"^BM_SummaryDisplay/repeats:2_cv %console_percentage_report[ ]*$"}});
720+
{"^BM_SummaryDisplay/repeats:2_stddev %console_time_only_report [ ]*2$"}});
729721
ADD_CASES(TC_JSONOut,
730722
{{".*BM_SummaryDisplay/repeats:2 ", MR_Not},
731723
{"\"name\": \"BM_SummaryDisplay/repeats:2_mean\",$"},
@@ -780,8 +772,7 @@ ADD_CASES(
780772
{"^BM_RepeatTimeUnit/repeats:3_median %console_us_time_only_report [ "
781773
"]*3$"},
782774
{"^BM_RepeatTimeUnit/repeats:3_stddev %console_us_time_only_report [ "
783-
"]*3$"},
784-
{"^BM_RepeatTimeUnit/repeats:3_cv %console_percentage_report[ ]*$"}});
775+
"]*3$"}});
785776
ADD_CASES(TC_JSONOut,
786777
{{".*BM_RepeatTimeUnit/repeats:3 ", MR_Not},
787778
{"\"name\": \"BM_RepeatTimeUnit/repeats:3_mean\",$"},
@@ -845,21 +836,20 @@ BENCHMARK(BM_UserStats)
845836

846837
// check that user-provided stats is calculated, and is after the default-ones
847838
// empty string as name is intentional, it would sort before anything else
848-
ADD_CASES(TC_ConsoleOut,
849-
{{"^BM_UserStats/iterations:5/repeats:3/manual_time [ "
850-
"]*150 ns [ ]*150 ns [ ]*%time [ ]*5$"},
851-
{"^BM_UserStats/iterations:5/repeats:3/manual_time [ "
852-
"]*150 ns [ ]*150 ns %time [ ]*5$"},
853-
{"^BM_UserStats/iterations:5/repeats:3/manual_time [ "
854-
"]*150 ns [ ]*150 ns %time [ ]*5$"},
855-
{"^BM_UserStats/iterations:5/repeats:3/"
856-
"manual_time_mean [ ]*150 ns [ ]*150 ns %time [ ]*3$"},
857-
{"^BM_UserStats/iterations:5/repeats:3/"
858-
"manual_time_median [ ]*150 ns [ ]*150 ns %time [ ]*3$"},
859-
{"^BM_UserStats/iterations:5/repeats:3/"
860-
"manual_time_stddev [ ]*0.000 ns [ ]*0.000 ns %time [ ]*3$"},
861-
{"^BM_UserStats/iterations:5/repeats:3/manual_time_cv "
862-
"%console_percentage_report[ ]*$"}});
839+
ADD_CASES(TC_ConsoleOut, {{"^BM_UserStats/iterations:5/repeats:3/manual_time [ "
840+
"]* 150 ns %time [ ]*5$"},
841+
{"^BM_UserStats/iterations:5/repeats:3/manual_time [ "
842+
"]* 150 ns %time [ ]*5$"},
843+
{"^BM_UserStats/iterations:5/repeats:3/manual_time [ "
844+
"]* 150 ns %time [ ]*5$"},
845+
{"^BM_UserStats/iterations:5/repeats:3/"
846+
"manual_time_mean [ ]* 150 ns %time [ ]*3$"},
847+
{"^BM_UserStats/iterations:5/repeats:3/"
848+
"manual_time_median [ ]* 150 ns %time [ ]*3$"},
849+
{"^BM_UserStats/iterations:5/repeats:3/"
850+
"manual_time_stddev [ ]* 0.000 ns %time [ ]*3$"},
851+
{"^BM_UserStats/iterations:5/repeats:3/manual_time_ "
852+
"[ ]* 150 ns %time [ ]*3$"}});
863853
ADD_CASES(
864854
TC_JSONOut,
865855
{{"\"name\": \"BM_UserStats/iterations:5/repeats:3/manual_time\",$"},
@@ -981,19 +971,19 @@ BENCHMARK(BM_UserPercentStats)
981971
// anything else
982972
ADD_CASES(TC_ConsoleOut,
983973
{{"^BM_UserPercentStats/iterations:5/repeats:3/manual_time [ "
984-
"]*150 ns [ ]*150 ns [ ]*%time [ ]*5$"},
974+
"]* 150 ns %time [ ]*5$"},
985975
{"^BM_UserPercentStats/iterations:5/repeats:3/manual_time [ "
986-
"]* 150 ns [ ]*150 ns [ ]*%time [ ]*5$"},
976+
"]* 150 ns %time [ ]*5$"},
987977
{"^BM_UserPercentStats/iterations:5/repeats:3/manual_time [ "
988-
"]* 150 ns [ ]*150 ns [ ]*%time [ ]*5$"},
978+
"]* 150 ns %time [ ]*5$"},
989979
{"^BM_UserPercentStats/iterations:5/repeats:3/"
990-
"manual_time_mean [ ]* 150 ns [ ]*150 ns [ ]*%time [ ]*3$"},
980+
"manual_time_mean [ ]* 150 ns %time [ ]*3$"},
991981
{"^BM_UserPercentStats/iterations:5/repeats:3/"
992-
"manual_time_median [ ]* 150 ns [ ]*150 ns [ ]*%time [ ]*3$"},
982+
"manual_time_median [ ]* 150 ns %time [ ]*3$"},
993983
{"^BM_UserPercentStats/iterations:5/repeats:3/"
994-
"manual_time_stddev [ ]* 0.000 ns [ ]*0.000 ns [ ]*%time [ ]*3$"},
995-
{"^BM_UserPercentStats/iterations:5/repeats:3/manual_time_cv "
996-
"%console_percentage_report[ ]*$"}});
984+
"manual_time_stddev [ ]* 0.000 ns %time [ ]*3$"},
985+
{"^BM_UserPercentStats/iterations:5/repeats:3/manual_time_ "
986+
"[ ]* 1.00 % [ ]* 1.00 %[ ]*3$"}});
997987
ADD_CASES(
998988
TC_JSONOut,
999989
{{"\"name\": \"BM_UserPercentStats/iterations:5/repeats:3/manual_time\",$"},

0 commit comments

Comments
 (0)