Module: Benchmark::IPS
- Included in:
- Benchmark
- Defined in:
- lib/benchmark/ips.rb,
lib/benchmark/ips/job.rb,
lib/benchmark/ips/report.rb
Overview
Benchmark in iterations per second, no more guessing!
Defined Under Namespace
Modules: Helpers Classes: Job, Report
Constant Summary collapse
- VERSION =
Benchmark-ips Gem version.
"2.1.0"- CODENAME =
CODENAME of current version.
"Springtime Hummingbird Dance"
Class Method Summary collapse
-
.options ⇒ Object
Set options for running the benchmarks.
Instance Method Summary collapse
-
#ips(time = nil, warmup = nil) {|job| ... } ⇒ Report
Measure code in block, each code’s benchmarked result will display in iteration per second with standard deviation in given time.
Class Method Details
.options ⇒ Object
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
68 69 70 |
# File 'lib/benchmark/ips.rb', line 68 def self. ||= {:format => :human} end |
Instance Method Details
#ips(time = nil, warmup = nil) {|job| ... } ⇒ Report
Measure code in block, each code’s benchmarked result will display in iteration per second with standard deviation in given time.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/benchmark/ips.rb', line 24 def ips(time=nil, warmup=nil) 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 $stdout.puts "Calculating -------------------------------------" unless quiet job.run_warmup $stdout.puts "-------------------------------------------------" unless quiet job.run $stdout.sync = sync if job.compare? job.run_comparison end return job.full_report end |