From 70ca86122f56ac07864bdc370b37487b7d8e9dc9 Mon Sep 17 00:00:00 2001 From: Lance Ivy Date: Thu, 28 Mar 2013 09:39:04 -0400 Subject: [PATCH] benchmark for loading all of fog vs just aws --- benchs/load_times.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 benchs/load_times.rb diff --git a/benchs/load_times.rb b/benchs/load_times.rb new file mode 100644 index 000000000..2d226dc70 --- /dev/null +++ b/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' }