Permalink
Browse files

changelog and benchmark for #502

Using require_relative instead of require results in a roughly 12%
improvement in the time it takes to load rspec-core's own lib files
  • Loading branch information...
dchelimsky committed Nov 13, 2011
1 parent 032f373 commit c59cdf82da205b706b1fa38dae8ac7ba19a354db
Showing with 52 additions and 0 deletions.
  1. +1 −0 Changelog.md
  2. +51 −0 benchmarks/require_relative_v_require.rb
View
@@ -9,6 +9,7 @@ Enhancments
* deletes obsolete files (on confirmation)
* merged with and deprecates `--configure` command, which generated
`.rspec`
+* use `require_relative` when available (Ian Leitch)
### 2.8.0.rc1 / 2011-11-06
@@ -0,0 +1,51 @@
+require 'benchmark'
+
+n = 20
+
+Benchmark.benchmark do |bm|
+ 3.times.each do
+ bm.report do
+ n.times do
+ pid = fork do
+ require 'rspec/core'
+ end
+ Process.wait(pid)
+ end
+ end
+ end
+end
+
+# ###################################
+# Ruby 1.9.3 - 3 x 20
+# require
+# $ bundle exec ruby benchmarks/require_relative_v_require.rb
+# 0.000000 0.020000 2.540000 ( 2.568784)
+# 0.000000 0.010000 2.550000 ( 2.580621)
+# 0.000000 0.020000 2.510000 ( 2.548631)
+#
+# require_relative
+# $ bundle exec ruby benchmarks/require_relative_v_require.rb
+# 0.000000 0.010000 2.220000 ( 2.288229)
+# 0.000000 0.010000 2.250000 ( 2.289886)
+# 0.000000 0.020000 2.260000 ( 2.296639)
+#
+# roughly 12% improvement
+#
+# ###################################
+#
+# Ruby 1.8.7 - 3 x 20
+# before change (using require, but no conditional)
+# $ bundle exec ruby benchmarks/require_relative_v_require.rb
+# 0.000000 0.010000 1.210000 ( 1.242291)
+# 0.000000 0.010000 1.230000 ( 1.259518)
+# 0.000000 0.010000 1.230000 ( 1.250333)
+#
+# after change (still using require, but adding conditional)
+# $ bundle exec ruby benchmarks/require_relative_v_require.rb
+# 0.000000 0.010000 1.200000 ( 1.227249)
+# 0.000000 0.010000 1.230000 ( 1.257012)
+# 0.000000 0.010000 1.230000 ( 1.259278)
+#
+# virtually no penalty
+#
+# ###################################

0 comments on commit c59cdf8

Please sign in to comment.