Created
January 30, 2012 18:21
-
-
Save labocho/1705787 to your computer and use it in GitHub Desktop.
CarrierWave Benchmark (URL generating for AWS private bucket)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$LOAD_PATH << File.expand_path("lib") # carrierwave/lib path | |
require "carrierwave" | |
require "benchmark" | |
CarrierWave.configure do |config| | |
config.fog_credentials = { | |
:provider => 'AWS', | |
:aws_access_key_id => 'foo', | |
:aws_secret_access_key => 'bar', | |
} | |
config.fog_directory = 'carrierwave-benchmark' | |
config.fog_public = false | |
end | |
class FooUploader < CarrierWave::Uploader::Base | |
storage :fog | |
end | |
# Ignore first time | |
uploader = FooUploader.new | |
uploader.retrieve_from_store!("image.png") | |
uploader.url | |
Benchmark.bm do |x| | |
x.report { | |
300.times do |i| | |
uploader = FooUploader.new | |
uploader.retrieve_from_store!("image_#{i}.png") | |
uploader.url | |
end | |
} | |
end | |
# No caching fog connection | |
# user system total real | |
# 12.200000 0.150000 12.350000 ( 12.348581) | |
# | |
# Caching fog connection | |
# user system total real | |
# 0.190000 0.000000 0.190000 ( 0.196306) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment