Last active
April 30, 2021 11:34
-
-
Save alloy/6249335 to your computer and use it in GitHub Desktop.
RSpec boot times vs smaller test frameworks.
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
$:.unshift(File.expand_path('..', __FILE__)) | |
require 'bowling' | |
describe Bowling, "#score" do | |
it "returns 0 for all gutter game" do | |
bowling = Bowling.new | |
20.times { bowling.hit(0) } | |
bowling.score.should == 0 | |
end | |
end |
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
class Bowling | |
def hit(pins) | |
end | |
def score | |
0 | |
end | |
end |
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
$:.unshift(File.expand_path('..', __FILE__)) | |
require 'bowling' | |
describe Bowling, "#score" do | |
it "returns 0 for all gutter game" do | |
bowling = Bowling.new | |
20.times { bowling.hit(0) } | |
bowling.score.should == 0 | |
end | |
end |
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
~/t/rspec-vs-small » ruby -v | |
ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-darwin12.2.0] | |
~/t/rspec-vs-small » gem install rspec peck bacon | |
Successfully installed rspec-2.14.1 | |
Successfully installed peck-0.3.0 | |
Successfully installed bacon-1.2.0 | |
3 gems installed | |
~/t/rspec-vs-small » ruby time.rb | |
Bacon: 0.2515 | |
Peck: 0.26 | |
RSpec: 0.39749999999999996 |
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
$:.unshift(File.expand_path('..', __FILE__)) | |
require 'bowling' | |
describe Bowling, "#score" do | |
it "returns 0 for all gutter game" do | |
bowling = Bowling.new | |
20.times { bowling.hit(0) } | |
bowling.score.should eq(0) | |
end | |
end |
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
require 'open3' | |
SAMPLE_SIZE = 20 | |
def time(*command) | |
total = 0 | |
SAMPLE_SIZE.times do | |
_, __, stderr = Open3.popen3('time', '-p', *command) | |
output = stderr.gets(nil) | |
line = output.strip.split("\n")[-3] | |
real = line.match(/\d\.\d\d/)[0] | |
total += real.to_f | |
end | |
total / SAMPLE_SIZE | |
end | |
STDOUT.sync = true | |
print "Bacon: " | |
puts time('bacon', 'bacon_example.rb') | |
print "Peck: " | |
puts time('ruby', '-r', 'rubygems', '-r', 'peck/flavors/vanilla', 'peck_example.rb') | |
print "RSpec: " | |
puts time('rspec', 'rspec_example.rb') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment