Created
August 13, 2014 14:19
-
-
Save shenmao1989/5567c0b251816f2cb102 to your computer and use it in GitHub Desktop.
ssdb bug test
This file contains 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
// 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