module Benchmark::IPS
def self.options
:human format narrows precision and scales results for readability
:format => [:human, :raw]
Set options for running the benchmarks.
def self.options @options ||= {:format => :human} end
def ips(*args)
-
(Report)
-
Parameters:
-
warmup
(Integer
) -- Specify how long should Warmup time run in seconds. -
time
(Integer
) -- Specify how long should benchmark your code in seconds.
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 sync, $stdout.sync = $stdout.sync, true job = Job.new job_opts = {} job_opts[:time] = time unless time.nil? job_opts[:warmup] = warmup unless warmup.nil? job_opts[:quiet] = quiet unless quiet.nil? job.config job_opts yield job job.load_held_results job.run if job.run_single? && job.all_results_have_been_run? job.clear_held_results else job.save_held_results puts '', 'Pausing here -- run Ruby again to measure the next benchmark...' if job.run_single? end $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