File: autoload_v_require.rb

package info (click to toggle)
ruby-rspec 3.4.0c3e0m1s1-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 6,124 kB
  • sloc: ruby: 59,418; sh: 1,405; makefile: 98
file content (25 lines) | stat: -rw-r--r-- 619 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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!)