-
Notifications
You must be signed in to change notification settings - Fork 0
/
fog_vs.rb
106 lines (99 loc) · 2.63 KB
/
fog_vs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
require 'rubygems'
require 'aws/s3'
require 'benchmark'
require 'right_aws'
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
data = File.open(File.expand_path('~/.fog')).read
config = YAML.load(data)[:default]
fog = Fog::AWS::S3.new(
:aws_access_key_id => config[:aws_access_key_id],
:aws_secret_access_key => config[:aws_secret_access_key]
)
raws = RightAws::S3Interface.new(
config[:aws_access_key_id],
config[:aws_secret_access_key]
)
raws.logger.level = 3 # ERROR
awss3 = AWS::S3::Base.establish_connection!(
:access_key_id => config[:aws_access_key_id],
:secret_access_key => config[:aws_secret_access_key],
:persistent => true
)
TIMES = 10
Benchmark.bmbm(25) do |bench|
bench.report('fog.put_bucket') do
TIMES.times do |x|
fog.put_bucket("fogbench#{x}")
end
end
bench.report('raws.create_bucket') do
TIMES.times do |x|
raws.create_bucket("rawsbench#{x}")
end
end
bench.report('awss3::Bucket.create') do
TIMES.times do |x|
AWS::S3::Bucket.create("awss3bench#{x}")
end
end
bench.report('fog.put_object') do
TIMES.times do |x|
TIMES.times do |y|
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
fog.put_object("fogbench#{x}", "lorem_#{y}", file)
end
end
end
bench.report('raws.put') do
TIMES.times do |x|
TIMES.times do |y|
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
raws.put("rawsbench#{x}", "lorem_#{y}", file)
end
end
end
bench.report('awss3::S3Object.create') do
TIMES.times do |x|
TIMES.times do |y|
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
AWS::S3::S3Object.create("lorem_#{y}", file, "awss3bench#{x}")
end
end
end
bench.report('fog.delete_object') do
TIMES.times do |x|
TIMES.times do |y|
fog.delete_object("fogbench#{x}", "lorem_#{y}")
end
end
end
bench.report('raws.delete') do
TIMES.times do |x|
TIMES.times do |y|
raws.delete("rawsbench#{x}", "lorem_#{y}")
end
end
end
bench.report('awss3::S3Object.delete') do
TIMES.times do |x|
TIMES.times do |y|
AWS::S3::S3Object.delete("lorem_#{y}", "awss3bench#{x}")
end
end
end
bench.report('fog.delete_bucket') do
TIMES.times do |x|
fog.delete_bucket("fogbench#{x}")
end
end
bench.report('raws.delete_bucket') do
TIMES.times do |x|
raws.delete_bucket("rawsbench#{x}")
end
end
bench.report('awss3::Bucket.delete') do
TIMES.times do |x|
AWS::S3::Bucket.delete("awss3bench#{x}")
end
end
end