1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
# coding: utf-8
require 'minitest/autorun'
require 'benchmark'
require 'yaml'
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
require 'aliyun/oss'
require_relative 'config'
class TestLargeFile < Minitest::Test
def setup
client = Aliyun::OSS::Client.new(TestConf.creds)
@bucket = client.get_bucket(TestConf.bucket)
@prefix = 'tests/large_file/'
end
def get_key(k)
@prefix + k
end
def test_large_file_1gb
skip "don't run it by default"
key = get_key("large_file_1gb")
Benchmark.bm(32) do |bm|
bm.report("Upload with put_object: ") do
@bucket.put_object(key, :file => './large_file_1gb')
end
bm.report("Upload with resumable_upload: ") do
@bucket.resumable_upload(key, './large_file_1gb')
end
bm.report("Download with get_object: ") do
@bucket.get_object(key, :file => './large_file_1gb')
end
bm.report("Download with resumable_download: ") do
@bucket.resumable_download(key, './large_file_1gb')
end
end
end
def test_large_file_8gb
skip "don't run it by default"
key = get_key("large_file_8gb")
Benchmark.bm(32) do |bm|
bm.report("Upload with put_object: ") do
@bucket.put_object(key, :file => './large_file_8gb')
end
bm.report("Upload with resumable_upload: ") do
@bucket.resumable_upload(key, './large_file_8gb')
end
bm.report("Download with get_object: ") do
@bucket.get_object(key, :file => './large_file_8gb')
end
bm.report("Download with resumable_download: ") do
@bucket.resumable_download(key, './large_file_8gb')
end
end
end
end
|