Created
November 23, 2013 08:06
-
-
Save trevorrowe/7612077 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
namespace :benchmarks do | |
namespace :dynamodb do | |
task :get_item do | |
require 'benchmark' | |
require 'aws-sdk' | |
table_name = 'aws-sdk-core-benchmarks' | |
params = { | |
table_name: table_name, | |
key: { | |
"id" => { s: "1" }, | |
}, | |
attributes_to_get: ["id"], | |
consistent_read: false, | |
return_consumed_capacity: "NONE", | |
} | |
json_params = { | |
'TableName' => table_name, | |
'Key' => { | |
"id" => { 'S' => '1' }, | |
}, | |
'AttributesToGet' => ["id"], | |
'ConsistentRead' => false, | |
'ReturnConsumedCapacity' => "NONE", | |
} | |
ddb_v1 = AWS.dynamodb | |
ddb_struct = Aws.dynamodb | |
ddb_json = Aws.dynamodb(raw_json: true) | |
ddb_v1.get_item(params) | |
ddb_struct.get_item(params) | |
ddb_json.get_item(json_params) | |
label = "%10s" | |
n = 50 | |
Benchmark.bm do |x| | |
x.report(label % "v1") { n.times { ddb_v1.get_item(params) }} | |
x.report(label % "v2 Struct") { n.times { ddb_struct.get_item(params) }} | |
x.report(label % "v2 JSON") { n.times { ddb_json.get_item(json_params) }} | |
end | |
end | |
end | |
end |
This file contains hidden or 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
Sample results with a run of 100 calls each: | |
``` | |
$ rake benchmarks:dynamodb:get_item | |
user system total real | |
v1 0.180000 0.010000 0.190000 ( 1.011285) | |
v2 Struct 0.190000 0.000000 0.190000 ( 0.988390) | |
v2 JSON 0.190000 0.000000 0.190000 ( 0.794811) | |
``` | |
Sample results with a run of 50 calls each: | |
``` | |
$ rake benchmarks:dynamodb:get_item | |
user system total real | |
v1 0.110000 0.010000 0.120000 ( 0.366370) | |
v2 Struct 0.080000 0.000000 0.080000 ( 0.351170) | |
v2 JSON 0.100000 0.010000 0.110000 ( 0.342579) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment