I wanted to make this ALWAYS_INLINE to prevent flappy performance tests, but GCC complains it may not be inlined.
| 16 | // I wanted to make this ALWAYS_INLINE to prevent flappy performance tests, |
| 17 | // but GCC complains it may not be inlined. |
| 18 | static void formatReadable(double size, DB::WriteBuffer & out, |
| 19 | int precision, const char ** units, size_t units_size, double delimiter) |
| 20 | { |
| 21 | size_t i = 0; |
| 22 | for (; i + 1 < units_size && fabs(size) >= delimiter; ++i) |
| 23 | size /= delimiter; |
| 24 | |
| 25 | DB::DoubleConverter<false>::BufferType buffer; |
| 26 | double_conversion::StringBuilder builder{buffer, sizeof(buffer)}; |
| 27 | |
| 28 | const auto result = DB::DoubleConverter<false>::instance().ToFixed(size, precision, &builder); |
| 29 | |
| 30 | if (!result) |
| 31 | throw DB::Exception("Cannot print float or double number", DB::ErrorCodes::CANNOT_PRINT_FLOAT_OR_DOUBLE_NUMBER); |
| 32 | |
| 33 | out.write(buffer, builder.position()); |
| 34 | writeCString(units[i], out); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | void formatReadableSizeWithBinarySuffix(double value, DB::WriteBuffer & out, int precision) |
no test coverage detected