Module: RequireBench

Defined in:
lib/require_bench.rb,
lib/require_bench/version.rb

Constant Summary collapse

TIMINGS =
Hash.new { |h, k| h[k] = 0.0 }
SKIP_PATTERN =
skips
VERSION =
'1.0.2'

Class Method Summary collapse

Class Method Details

.require_with_timing(file) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/require_bench.rb', line 24

def require_with_timing(file)
  $require_bench_semaphore = true
  ret = nil
  seconds = Benchmark.realtime { ret = Kernel.send(:require_without_timing, file) }
  printf("[RequireBench] %10f %s\n", seconds, file)
  path_parts = file.split('/')
  prefix = path_parts.first
  # requires that were fully qualified paths probably need to be identified
  #   by the full path
  prefix = file if prefix.nil? || prefix.empty?
  RequireBench::TIMINGS[prefix] += seconds
  ret
ensure
  $require_bench_semaphore = nil
end