Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

benchmark improvement using autoload

  • Loading branch information...
commit a5b73688edd5ae6c357629799de12ebfac00e0e7 1 parent a0f5026
@dchelimsky dchelimsky authored
Showing with 34 additions and 0 deletions.
  1. +25 −0 benchmarks/autoload_v_require.rb
  2. +9 −0 benchmarks/example_spec.rb
View
25 benchmarks/autoload_v_require.rb
@@ -0,0 +1,25 @@
+require 'benchmark'
+
+n = 10
+
+Benchmark.benchmark do |bm|
+ 3.times do
+ bm.report do
+ n.times do
+ `bin/rspec benchmarks/example_spec.rb`
+ end
+ end
+ end
+end
+
+# Before autoloading matcher class files
+# 0.000000 0.010000 8.800000 ( 8.906383)
+# 0.010000 0.010000 8.880000 ( 8.980907)
+# 0.000000 0.010000 8.820000 ( 8.918083)
+#
+# After autoloading matcher class files
+# 0.000000 0.010000 8.610000 ( 8.701434)
+# 0.010000 0.010000 8.620000 ( 8.741811)
+# 0.000000 0.000000 8.580000 ( 8.677235)
+#
+# Roughly 2.5% improvement in load time (every bit counts!)
View
9 benchmarks/example_spec.rb
@@ -0,0 +1,9 @@
+describe "something" do
+ it "does something that passes" do
+ 1.should eq(1)
+ end
+
+ it "does something that fails" do
+ 1.should eq(2)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.