Sha256: dbac1292718464915438b6f80782ae419ee24885102ca513a858d4d85010da87

Contents?: true

Size: 774 Bytes

Versions: 11

Compression:

Stored size: 774 Bytes

Contents

module WBench
  class RowFormatter
    def initialize(name, data)
      @name  = name
      @stats = Stats.new(data)
    end

    def to_s
      if @stats.compact.size == 0
        name_s + no_result_s
      else
        name_s + fastest_s + median_s + slowest_s + std_dev_s
      end
    end

    private

    def name_s
      @name.ljust(35)
    end

    def no_result_s
      'Unable to be recorded'.center(40).colorize(:light_red)
    end

    def fastest_s
      "#{@stats.min}ms".ljust(10).colorize(:green)
    end

    def slowest_s
      "#{@stats.max}ms".ljust(10).colorize(:red)
    end

    def median_s
      "#{@stats.median}ms".ljust(10).colorize(:blue)
    end

    def std_dev_s
      "#{@stats.std_dev.to_i}ms".ljust(10).colorize(:yellow)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wbench-0.3.7 lib/wbench/row_formatter.rb
wbench-0.3.6 lib/wbench/row_formatter.rb
wbench-0.3.5 lib/wbench/row_formatter.rb
wbench-0.3.4 lib/wbench/row_formatter.rb
wbench-0.3.3 lib/wbench/row_formatter.rb
wbench-0.3.2 lib/wbench/row_formatter.rb
wbench-0.3.1 lib/wbench/row_formatter.rb
wbench-0.3.0 lib/wbench/row_formatter.rb
wbench-0.2.3 lib/wbench/row_formatter.rb
wbench-0.2.2 lib/wbench/row_formatter.rb
wbench-0.2.1 lib/wbench/row_formatter.rb