Created
July 22, 2012 01:35
-
-
Save jmervine/3157875 to your computer and use it in GitHub Desktop.
Benchmark A/B Test Suite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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