Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Created June 25, 2013 08:36
Show Gist options
  • Save toritori0318/5856934 to your computer and use it in GitHub Desktop.
Save toritori0318/5856934 to your computer and use it in GitHub Desktop.
dynode vs node-aws-sdk-dynamodb
var access_key = '';
var secret_key = '';
var region = 'ap-northeast-1';
var dynode = require('dynode');
dynode.auth({
accessKeyId: access_key
,secretAccessKey: secret_key
,region: region
});
var table = 'hoge';
var table_key_value = 'xxxxxxx';
var start = new Date().getTime();
// benchmark
var count=0
var max=3000
for (var i=0;i<max;i++) {
dynode.getItem(table, table_key_value, function (err, res) {
count++
if(max<=count) {
var end = new Date().getTime();
console.log('count-dynode is ' + count);
console.log('total time:' + ((end - start) / 1000)) + " sec";
}
if(err) return console.log(err);
});
}
////////////////////////////////////////////////////////////////////
// toritori0318-MBA-2:dynamodb:% node bench_dynode.js
// count-dynode is 3000
// total time:4.147
var access_key = '';
var secret_key = '';
var region = 'ap-northeast-1';
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: access_key
,secretAccessKey: secret_key
,region: region
});
var aws_dy = new AWS.DynamoDB();
var table = 'hoge';
var table_key_value = 'xxxxxx';
var start = new Date().getTime();
// benchmark
var count=0
var max=3000
for (var i=0;i<max;i++) {
aws_dy.getItem({TableName: table, Key: {id: {S: table_key_value}}}, function (err, res) {
count++
if(max<=count) {
var end = new Date().getTime();
console.log('count-sdk is ' + count);
console.log('total time:' + ((end - start) / 1000)) + " sec";
}
if(err) return console.log(err);
});
}
////////////////////////////////////////////////////////////////////
// toritori0318-MBA-2:dynamodb:% node bench_node_aws_sdk.js
// count-sdk is 3000
// total time:5.206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment