2009-06-09 01:47:45 -04:00
|
|
|
require 'rubygems'
|
|
|
|
require 'benchwarmer'
|
|
|
|
require 'right_aws'
|
|
|
|
|
2009-06-23 03:04:29 -04:00
|
|
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2009-06-09 01:47:45 -04:00
|
|
|
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
|
|
|
|
|
2009-06-23 03:04:29 -04:00
|
|
|
TIMES = 100
|
2009-06-09 15:09:40 -04:00
|
|
|
|
2009-06-23 03:16:08 -04:00
|
|
|
Benchmark.bmbm(25) do |bench|
|
2009-06-09 01:47:45 -04:00
|
|
|
bench.report('fog.put_bucket') do
|
|
|
|
fog.put_bucket('fogbench')
|
|
|
|
end
|
|
|
|
bench.report('raws.create_bucket') do
|
|
|
|
raws.create_bucket('rawsbench')
|
|
|
|
end
|
|
|
|
|
|
|
|
bench.report('fog.put_object') do
|
2009-06-09 15:09:40 -04:00
|
|
|
TIMES.times do |x|
|
2009-06-23 03:04:29 -04:00
|
|
|
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
|
2009-06-09 01:47:45 -04:00
|
|
|
end
|
|
|
|
bench.report('raws.put') do
|
2009-06-09 15:09:40 -04:00
|
|
|
TIMES.times do |x|
|
2009-06-23 03:04:29 -04:00
|
|
|
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
|
2009-06-09 01:47:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2009-06-09 01:47:45 -04:00
|
|
|
end
|
|
|
|
bench.report('raws.delete') do
|
2009-06-09 15:09:40 -04:00
|
|
|
TIMES.times do |x|
|
|
|
|
raws.delete('rawsbench', "lorem_#{x}")
|
|
|
|
end
|
2009-06-09 01:47:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
bench.report('fog.delete_bucket') do
|
|
|
|
fog.delete_bucket('fogbench')
|
|
|
|
end
|
|
|
|
bench.report('raws.delete_bucket') do
|
|
|
|
raws.delete_bucket('rawsbench')
|
|
|
|
end
|
2009-06-23 03:04:29 -04:00
|
|
|
end
|