| 102 | } |
| 103 | |
| 104 | static 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 | |
| 126 | BENCHMARK_EXPORT |
| 127 | void ConsoleReporter::PrintRunData(const Run& result) { |
no test coverage detected