Skip to content

Instantly share code, notes, and snippets.

@shenmao1989
Created August 13, 2014 14:19
Show Gist options
  • Save shenmao1989/5567c0b251816f2cb102 to your computer and use it in GitHub Desktop.
Save shenmao1989/5567c0b251816f2cb102 to your computer and use it in GitHub Desktop.
ssdb bug test
// SSDB
var SSDB = require('ssdb');
__SSDB = SSDB.createClient({
host: '127.0.0.1',
port: 8888,
timeout: 10
});
__SSDB.thunkify();
var co = require('co');
co(function* (){
var times = 10;
var key = 'key';
var params = [key];
console.time('a');
for(var i = 0; i < times; i++){
params.push(randomString(65536));
}
var a = yield __SSDB.qpush_front.apply(null, params);
for(var i = 0; i < times; i++){
var t = yield __SSDB.qpop_front(key);
}
console.timeEnd('a');
})();
function randomString(length) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
if (! length) {
length = Math.floor(Math.random() * chars.length);
}
var str = '';
for (var i = 0; i < length; i++) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment