File: advanced.rb

package info (click to toggle)
ruby-benchmark-ips 2.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 188 kB
  • sloc: ruby: 807; makefile: 11
file content (20 lines) | stat: -rw-r--r-- 343 bytes parent folder | download
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