# module Benchmark::IPS::Helpers

### Public Class Methods

scale(value) click to toggle source

    # File lib/benchmark/ips.rb, line 84
    def scale(value)
      scale = (Math.log10(value) / 3).to_i
      suffix = case scale
      when 1; 'k'
      when 2; 'M'
      when 3; 'B'
      when 4; 'T'
      when 5; 'Q'
      else
        # < 1000 or > 10^15, no scale or suffix
        scale = 0
        ' '
      end
      "%10.3f#{suffix}" % (value.to_f / (1000 ** scale))
    end