Sha256: 5d8ffc20ac1d8ca0d492d326be94584e90cb04cbc2f90c7062edfeec268559e8

Contents?: true

Size: 1.13 KB

Versions: 69

Compression:

Stored size: 1.13 KB

Contents

# Monkey patch to show milliseconds
module Benchmark
  module IPS
    class Report
      module EntryExtension
        def body
          return super if Benchmark::IPS.options[:format] != :human

          left = "%s i/s (%1.3fms)" % [Helpers.scale(ips), (1000.0 / ips)]
          iters = Helpers.scale(@iterations)

          if @show_total_time
            left.ljust(20) + (" - %s in %10.6fs" % [iters, runtime])
          else
            left.ljust(20) + (" - %s" % iters)
          end
        end
      end
      Entry.prepend(EntryExtension)
    end
  end

  module CompareExtension
    def compare(*reports)
      return if reports.size < 2

      sorted = reports.sort_by(&:ips).reverse
      best = sorted.shift
      $stdout.puts "\nComparison:"
      $stdout.printf "%20s: %10.1f i/s (%1.3fms)\n", best.label, best.ips, (1000.0 / best.ips)

      sorted.each do |report|
        name = report.label.to_s

        x = (best.ips.to_f / report.ips.to_f)
        $stdout.printf "%20s: %10.1f i/s (%1.3fms) - %.2fx slower\n", name, report.ips, (1000.0 / report.ips), x
      end

      $stdout.puts
    end
  end
  extend CompareExtension
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
hamlit-2.15.0-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.15.0 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.6 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.6-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.5-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.5 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.4 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.4-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.3-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.3 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.2-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.2 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.0 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.0-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.1-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.14.1 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.13.2-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.13.2 benchmark/utils/benchmark_ips_extension.rb
hamlit-2.13.1-java benchmark/utils/benchmark_ips_extension.rb
hamlit-2.13.1 benchmark/utils/benchmark_ips_extension.rb