Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
benchmark for loading all of fog vs just aws
  • Loading branch information
cainlevy committed Mar 28, 2013
1 parent e5c438a commit 70ca861
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions benchs/load_times.rb
@@ -0,0 +1,31 @@
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

N = 10

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

0 comments on commit 70ca861

Please sign in to comment.