MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / bytesToString

Function bytesToString

src/backend/common/Logger.cpp:53–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53string 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

Callers 6

nativeAllocMethod · 0.85
nativeAllocMethod · 0.85
nativeAllocMethod · 0.85
setMaxMemorySizeMethod · 0.85
nativeAllocMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected