Created
March 30, 2011 13:22
-
-
Save txus/894367 to your computer and use it in GitHub Desktop.
Test Framework Benchmark
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
$ gem install minitest rspec | |
$ time ruby rspec.rb && time ruby minispec.rb && time ruby minitest.rb | |
................ | |
Finished in 0.01554 seconds | |
16 examples, 0 failures | |
ruby rspec.rb 0.21s user 0.08s system 99% cpu 0.290 total | |
------------------------------- | |
Loaded suite minispec | |
Started | |
................ | |
Finished in 0.001028 seconds. | |
16 tests, 115 assertions, 0 failures, 0 errors, 0 skips | |
Test run options: --seed 21392 | |
ruby minispec.rb 0.03s user 0.01s system 96% cpu 0.041 total | |
------------------------------- | |
Loaded suite minitest | |
Started | |
................ | |
Finished in 0.000801 seconds. | |
16 tests, 115 assertions, 0 failures, 0 errors, 0 skips | |
Test run options: --seed 29847 | |
ruby minitest.rb 0.03s user 0.01s system 96% cpu 0.039 total |
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 'minitest/spec' | |
require 'minitest/autorun' | |
describe "MiniSpec" do | |
before do | |
@numbers = 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 | |
end | |
it "is fast" do | |
(1..50).each do |n| | |
n.must_equal(n) | |
refute_nil n | |
end | |
end | |
(1..15).each do |n| | |
it "is example #{n}" do | |
refute_nil (1 * @numbers) | |
end | |
end | |
after(:each) do | |
@numbers = nil | |
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 'minitest/unit' | |
require 'minitest/autorun' | |
class MinitestTest < MiniTest::Unit::TestCase | |
def setup | |
@numbers = 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 | |
end | |
def teardown | |
@numbers = nil | |
end | |
def test_is_fast | |
(1..50).each do |n| | |
assert_equal n, n | |
refute n.zero? | |
end | |
end | |
(1..15).each do |n| | |
define_method("test_is_example#{n}") do | |
refute_nil (1 * @numbers) | |
end | |
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 'rspec/core' | |
describe "RSpec" do | |
before(:each) do | |
@numbers = 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 | |
end | |
it "is fast" do | |
(1..50).each do |n| | |
n.should eq(n) | |
n.should_not be_zero | |
end | |
end | |
(1..15).each do |n| | |
it "is example #{n}" do | |
(1 * @numbers).should_not be_nil | |
end | |
end | |
after(:each) do | |
@numbers = nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment