Return the SI representation of a number in bytes. */
| 48 | |
| 49 | /** Return the SI representation of a number in bytes. */ |
| 50 | static inline std::string bytesToSI(size_t n) |
| 51 | { |
| 52 | std::ostringstream s; |
| 53 | s << std::setprecision(3); |
| 54 | if (n < 1024) |
| 55 | s << n; |
| 56 | else if (n < (1ULL<<20)) |
| 57 | s << (double)n/(1ULL<<10) << "k"; |
| 58 | else if (n < (1ULL<<30)) |
| 59 | s << (double)n/(1ULL<<20) << "M"; |
| 60 | else |
| 61 | s << (double)n/(1ULL<<30) << "G"; |
| 62 | return s.str(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Convert a quantity with SI units to the equivalent floating |