Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created March 30, 2011 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mraleph/895186 to your computer and use it in GitHub Desktop.
Save mraleph/895186 to your computer and use it in GitHub Desktop.
var s = "qwertyuiop";
for (var i = 0; i < 10; i++) s += s;
s.charCodeAt();
function str2buffer(s) {
var length = s.length;
var b = new Buffer(length);
for (var i = 0; i < length; i++) b[i] = s.charCodeAt(i);
return b;
}
var start = Date.now();
for (var i = 0; i < 1000; i++) {
str2buffer(s);
}
var end = Date.now();
console.log(end - start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment