Sha256: d2f55f5376f8d182847c877d5a28dfb5c91d9d56a071ecf26d4f3dd746ed2fdc

Contents?: true

Size: 804 Bytes

Versions: 49

Compression:

Stored size: 804 Bytes

Contents

require 'benchmark'
$LOAD_PATH << File.dirname(__FILE__) + '/../lib'

def time_in_fork(&block)
  read, write = IO.pipe
  Process.fork do
    write.puts Benchmark.realtime{ block.call }
  end
  Process.wait
  write.close
  read.read.tap do
    read.close
  end
end

class Array
  def avg
    map(&:to_f).inject(:+) / size
  end
end

def report(label, n = 10, &block)
  puts label
  puts "%.4f" % n.times.map{ time_in_fork &block }.avg
  puts
end

# make rubygems load specifications now so the
# time is not included below.
Gem::Specification._all

N = 10

report("require fog:", N)             { require 'fog' }
report("require fog/aws:", N)         { require 'fog/aws' }
report("require fog/aws/compute:", N) { require 'fog/aws/compute' }
report("require fog/aws/core:", N)    { require 'fog/aws/core'}

Version data entries

49 entries across 47 versions & 8 rubygems

Version Path
fog-2.3.0 benchs/load_times.rb
fog-ifeel-2.2.0 benchs/load_times.rb
fog-2.2.0 benchs/load_times.rb
fog-2.1.0 benchs/load_times.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/benchs/load_times.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/benchs/load_times.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/benchs/load_times.rb
fog-1.42.1 benchs/load_times.rb
fog-2.0.0 benchs/load_times.rb
fog-1.42.0 benchs/load_times.rb
fog-1.41.0 benchs/load_times.rb
fog-1.40.0 benchs/load_times.rb
fog-1.39.0 benchs/load_times.rb
fog-digitalocean-0.1.0 benchs/load_times.rb
fog-1.38.0 benchs/load_times.rb
fog-1.37.0 benchs/load_times.rb
fog-1.36.0 benchs/load_times.rb
fog-1.35.0 benchs/load_times.rb
fog-2.0.0.pre.0 benchs/load_times.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/benchs/load_times.rb