1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/bench.rb
2009-06-09 12:09:40 -07:00

66 lines
No EOL
1.5 KiB
Ruby

require 'rubygems'
require 'benchwarmer'
require 'right_aws'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
require 'fog/aws'
data = File.open(File.expand_path('~/.s3conf/s3config.yml')).read
config = YAML.load(data)
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
TIMES = 10
Benchmark.bm(25) do |bench|
bench.report('fog.put_bucket') do
fog.put_bucket('fogbench')
end
bench.report('raws.create_bucket') do
raws.create_bucket('rawsbench')
end
print '-' * 64 << "\n"
bench.report('fog.put_object') do
TIMES.times do |x|
file = File.open(File.dirname(__FILE__) + '/spec/lorem.txt', 'r')
fog.put_object('fogbench', "lorem_#{x}", file)
end
end
bench.report('raws.put') do
TIMES.times do |x|
file = File.open(File.dirname(__FILE__) + '/spec/lorem.txt', 'r')
raws.put('rawsbench', "lorem_#{x}", file)
end
end
print '-' * 64 << "\n"
bench.report('fog.delete_object') do
TIMES.times do |x|
fog.delete_object('fogbench', "lorem_#{x}")
end
end
bench.report('raws.delete') do
TIMES.times do |x|
raws.delete('rawsbench', "lorem_#{x}")
end
end
print '-' * 64 << "\n"
bench.report('fog.delete_bucket') do
fog.delete_bucket('fogbench')
end
bench.report('raws.delete_bucket') do
raws.delete_bucket('rawsbench')
end
end