Skip to content

Instantly share code, notes, and snippets.

@jmervine
Created July 22, 2012 01:35
Show Gist options
  • Save jmervine/3157875 to your computer and use it in GitHub Desktop.
Save jmervine/3157875 to your computer and use it in GitHub Desktop.
Benchmark A/B Test Suite
#!/usr/bin/env ruby
require 'benchmark'
# require libs here
iterations = ARGV[0]||100000 # pass in iterations or
#
# Control Test
def control
# what you're using or planning on using
# << your code goes here
end
#
# Test A
def test_a
# another way of doing control
# << your code goes here
end
#
# Test B
def test_b
# yet another way of doing control
# << your code goes here
end
Benchmark.bm do |bm|
# first report
bm.report('control') do
(1..iterations).each do
control
end
end
# second report
bm.report('test_a') do
(1..iterations).each do
test_a
end
end
# third report
bm.report('test_b') do
(1..iterations).each do
test_b
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment