module Benchmark::IPS
Benchmark
in iterations per second, no more guessing! @see github.com/evanphx/benchmark-ips
Constants
- CODENAME
CODENAME
of current version.- VERSION
Benchmark-ips Gem version.
Public Class Methods
options()
click to toggle source
Set options for running the benchmarks. :format => [:human, :raw]
:human format narrows precision and scales results for readability :raw format displays 6 places of precision and exact iteration counts
# File lib/benchmark/ips.rb, line 80 def self.options @options ||= {:format => :human} end
Public Instance Methods
ips(*args) { |job| ... }
click to toggle source
Measure code in block, each code's benchmarked result will display in iteration per second with standard deviation in given time. @param time [Integer] Specify how long should benchmark your code in seconds. @param warmup [Integer] Specify how long should Warmup time run in seconds. @return [Report]
# File lib/benchmark/ips.rb, line 28 def ips(*args) if args[0].is_a?(Hash) time, warmup, quiet = args[0].values_at(:time, :warmup, :quiet) else time, warmup, quiet = args end suite = nil sync, $stdout.sync = $stdout.sync, true if defined? Benchmark::Suite and Suite.current suite = Benchmark::Suite.current end quiet ||= (suite && suite.quiet?) job = Job.new({:suite => suite, :quiet => quiet }) job_opts = {} job_opts[:time] = time unless time.nil? job_opts[:warmup] = warmup unless warmup.nil? job.config job_opts yield job job.load_held_results if job.hold? && job.held_results? job.run $stdout.sync = sync job.run_comparison job.generate_json report = job.full_report if ENV['SHARE'] || ENV['SHARE_URL'] require 'benchmark/ips/share' share = Share.new report, job share.share end report end