Method: MemoryProfiler::Results#scale_bytes
- Defined in:
- lib/memory_profiler/results.rb
#scale_bytes(bytes) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/memory_profiler/results.rb', line 77 def scale_bytes(bytes) return "0 B" if bytes.zero? scale = Math.log10(bytes).div(3) * 3 scale = 24 if scale > 24 "%.2f #{UNIT_PREFIXES[scale]}" % (bytes / 10.0**scale) end |