Skip to content

Instantly share code, notes, and snippets.

@janko
Last active August 29, 2015 14:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save janko/0fc6b921020b80143c31 to your computer and use it in GitHub Desktop.
Save janko/0fc6b921020b80143c31 to your computer and use it in GitHub Desktop.
Minitest loads *slower* than RSpec?
require "benchmark/ips"
File.write "minitest_test.rb", <<-EOS
require "minitest/autorun"
require "minitest/pride"
class MintestTest < Minitest::Test
def test_foo
assert true
end
end
EOS
File.write "rspec_spec.rb", <<-EOS
require "rspec/autorun"
RSpec.describe "RSpec" do
it "foo" do
expect(true).to eq true
end
end
EOS
Benchmark.ips do |x|
x.config(time: 10)
x.report("rspec") { `ruby rspec_spec.rb` }
x.report("minitest") { `ruby minitest_test.rb` }
x.compare!
end
# Calculating -------------------------------------
# rspec 1.000 i/100ms
# minitest 1.000 i/100ms
# -------------------------------------------------
# rspec 4.545 (± 0.0%) i/s - 46.000
# minitest 3.951 (± 0.0%) i/s - 40.000
#
# Comparison:
# rspec: 4.5 i/s
# minitest: 4.0 i/s - 1.15x slower
@mislav
Copy link

mislav commented Apr 10, 2015

In my fork I've rewritten your benchmark: https://gist.github.com/mislav/8ae7ca40feb7c967ef32#file-readme-md

Turns out there isn't much of a difference. Startup times of these test libraries don't matter anyway; so based on just that it's not really fair to say "X is faster than Y".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment