Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

benchmark

dallasmarlow edited this page · 17 revisions
Clone this wiki locally
require 'benchmark'
require 's3_multi_upload'

config = {
  :access_key_id     => 'xxx',
  :secret_access_key => 'xxx',
  :bucket            => :s3_multi_upload,
  :file              => 'ubuntu-12.04-beta2-dvd-amd64.iso', # 1.6 gb
}

# setup s3 client for serial test
AWS.config :access_key_id     => config[:access_key_id],
           :secret_access_key => config[:secret_access_key]

s3     = AWS::S3.new
bucket = s3.buckets.create config[:bucket]


Benchmark.bm(10) do |benchmark|

  # multipart upload in serial
  benchmark.report 'serial' do
    100.times do
      object = bucket.objects[config[:file]]
      object.write :file => config[:file],
                   :multipart_threshold => 25 * 1024 ** 2 # 25 mb
    end
  end

  # threaded multipart upload
  benchmark.report 'parallel' do
    100.times do
      object = S3_Multi_Upload::Upload.new :access_key_id     => config[:access_key_id],
                                           :secret_access_key => config[:secret_access_key],
                                           :bucket            => config[:bucket],
                                           :file              => config[:file],
                                           :threads           => 20,
                                           :chunk_size        => {25 => :mb}
    end
  end

end
Something went wrong with that request. Please try again.