zircon/system/utest/blobfs-bench/blobfs-bench.cc
// Get a readable name for a given number of bytes.
Get a readable name for a given number of bytes.
Get a readable name for a given number of bytes .
fbl::String GetNameForSize(size_t size_in_bytes) {
  static const char* const kUnits[] = {"bytes", "Kbytes", "Mbytes", "Gbytes"};
  size_t current_unit = 0;
  size_t current_size = size_in_bytes;
  size_t size;
  while (current_unit < std::size(kUnits) && current_size >= (1u << (10 * (current_unit + 1)))) {
    current_size = current_size / (1 << 10 * current_unit);
    ++current_unit;
  }
  size = (size_in_bytes >> (10 * current_unit));
  return fbl::StringPrintf("%lu%s", size, kUnits[current_unit]);
}
fbl :: String GetNameForSize ( size_t size_in_bytes ) { static const char * const kUnits [ ] = { " " , " " , " " , " " } ; size_t current_unit = 0 ; size_t current_size = size_in_bytes ; size_t size ; while ( current_unit < std :: size ( kUnits ) && current_size >= ( 1u << ( 10 * ( current_unit + 1 ) ) ) ) { current_size = current_size / ( 1 << 10 * current_unit ) ; ++ current_unit ; } size = ( size_in_bytes >> ( 10 * current_unit ) ) ; return fbl :: StringPrintf ( " " , size , kUnits [ current_unit ] ) ; }
Get a readable name for a given number of bytes.
Get a readable name for a given number of bytes .