| 51 | } |
| 52 | |
| 53 | string bytesToString(size_t bytes) { |
| 54 | constexpr array<const char*, 7> units{ |
| 55 | {"B", "KB", "MB", "GB", "TB", "PB", "EB"}}; |
| 56 | size_t count = 0; |
| 57 | auto fbytes = static_cast<double>(bytes); |
| 58 | size_t num_units = units.size(); |
| 59 | for (count = 0; count < num_units && fbytes > 1000.0f; count++) { |
| 60 | fbytes *= (1.0f / 1024.0f); |
| 61 | } |
| 62 | if (count == units.size()) { count--; } |
| 63 | return fmt::format("{:.3g} {}", fbytes, units[count]); |
| 64 | } |
| 65 | } // namespace common |
| 66 | } // namespace arrayfire |
no outgoing calls
no test coverage detected