File: advanced.rb

package info (click to toggle)
ruby-benchmark-ips 2.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 224 kB
  • sloc: ruby: 1,257; makefile: 11
file content (20 lines) | stat: -rw-r--r-- 343 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env ruby

require 'benchmark/ips'

Benchmark.ips do |x|

  # Use bootstrap confidence intervals
  x.stats = :bootstrap

  # Set confidence to 95%
  x.confidence = 95

  # Run multiple iterations for better warmup
  x.iterations = 3

  x.report("mul") { 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 }
  x.report("pow") { 2 ** 8 }

  x.compare!
end