Sha256: de57a3955942b9dcc3b35fc1cae76bf43f03e54005579ce24295e81982b9ef68

Contents?: true

Size: 1.31 KB

Versions: 11

Compression:

Stored size: 1.31 KB

Contents

module WBench
  class ResultsFormatter
    def initialize(results)
      @results = results
    end

    def to_s
      [ heading_s,
        spacer_s,
        app_heading_s,
        app_server_s,
        spacer_s,
        latency_heading_s,
        latency_s,
        spacer_s,
        browser_heading_s,
        browser_rows_s ].join
    end

    private

    def heading_s
      "\nTesting #{@results.url}" \
        "\nAt #{@results.time}" \
        + "\n#{@results.loops} loops\n" \
        + ''.center(35) \
        + 'Fastest'.ljust(10) \
        + 'Median'.ljust(10) \
        + 'Slowest'.ljust(10) \
        + 'Std Dev'.ljust(10) \
        + "\n" \
        + '-' * 75 \
    end

    def spacer_s
      "\n\n"
    end

    def browser_rows_s
      @results.browser.map { |browser, results| RowFormatter.new(Titleizer.new(browser).to_s, results) }.join("\n")
    end

    def app_server_s
      RowFormatter.new('Total application time', @results.app_server)
    end

    def latency_s
      @results.latency.map { |domain, values| RowFormatter.new(domain, values) }.join("\n")
    end

    def latency_heading_s
      "Host latency:\n".colorize(:yellow)
    end

    def browser_heading_s
      "Browser performance:\n".colorize(:yellow)
    end

    def app_heading_s
      "Server performance:\n".colorize(:yellow)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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