Skip to content

Commit 70ca861

Browse files
committed
benchmark for loading all of fog vs just aws
1 parent e5c438a commit 70ca861

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

benchs/load_times.rb

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'benchmark'
2+
$LOAD_PATH << File.dirname(__FILE__) + '/../lib'
3+
4+
def time_in_fork(&block)
5+
read, write = IO.pipe
6+
Process.fork do
7+
write.puts Benchmark.realtime{ block.call }
8+
end
9+
Process.wait
10+
write.close
11+
read.read.tap do
12+
read.close
13+
end
14+
end
15+
16+
class Array
17+
def avg
18+
map(&:to_f).inject(:+) / size
19+
end
20+
end
21+
22+
def report(label, n = 10, &block)
23+
puts label
24+
puts "%.4f" % n.times.map{ time_in_fork &block }.avg
25+
puts
26+
end
27+
28+
N = 10
29+
30+
report("require fog:", N) { require 'fog' }
31+
report("require fog/aws:", N) { require 'fog/aws' }

0 commit comments

Comments
 (0)