1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/benchs/fog_vs.rb

67 lines
1.5 KiB
Ruby
Raw Normal View History

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 = 100
2009-06-09 15:09:40 -04:00
2009-06-23 03:16:08 -04:00
Benchmark.bmbm(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
2009-06-09 15:09:40 -04:00
TIMES.times do |x|
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
2009-06-09 15:09:40 -04:00
fog.put_object('fogbench', "lorem_#{x}", file)
end
end
bench.report('raws.put') do
2009-06-09 15:09:40 -04:00
TIMES.times do |x|
file = File.open(File.dirname(__FILE__) + '/../spec/lorem.txt', 'r')
2009-06-09 15:09:40 -04:00
raws.put('rawsbench', "lorem_#{x}", file)
end
end
print '-' * 64 << "\n"
bench.report('fog.delete_object') do
2009-06-09 15:09:40 -04:00
TIMES.times do |x|
fog.delete_object('fogbench', "lorem_#{x}")
end
end
bench.report('raws.delete') do
2009-06-09 15:09:40 -04:00
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