MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / FormatTime

Function FormatTime

deps/google-benchmark/src/console_reporter.cc:104–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104static std::string FormatTime(double time) {
105 // For the time columns of the console printer 13 digits are reserved. One of
106 // them is a space and max two of them are the time unit (e.g ns). That puts
107 // us at 10 digits usable for the number.
108 // Align decimal places...
109 if (time < 1.0) {
110 return FormatString("%10.3f", time);
111 }
112 if (time < 10.0) {
113 return FormatString("%10.2f", time);
114 }
115 if (time < 100.0) {
116 return FormatString("%10.1f", time);
117 }
118 // Assuming the time ist at max 9.9999e+99 and we have 10 digits for the
119 // number, we get 10-1(.)-1(e)-1(sign)-2(exponent) = 5 digits to print.
120 if (time > 9999999999 /*max 10 digit number*/) {
121 return FormatString("%1.4e", time);
122 }
123 return FormatString("%10.0f", time);
124}
125
126BENCHMARK_EXPORT
127void ConsoleReporter::PrintRunData(const Run& result) {

Callers 1

PrintRunDataMethod · 0.85

Calls 1

FormatStringFunction · 0.85

Tested by

no test coverage detected