Skip to content

Instantly share code, notes, and snippets.

@Jonathancollinet
Created July 13, 2017 22:05
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 Jonathancollinet/26d6e2bad49f204f10fe85ec18f28e2a to your computer and use it in GitHub Desktop.
Save Jonathancollinet/26d6e2bad49f204f10fe85ec18f28e2a to your computer and use it in GitHub Desktop.
const msgpack = require('msgpack'),
os = require('os');
for(let r = 1; r < 4; r++) {
console.log("\nRun #" + r + ":");
const obj = {'abcdef' : 1, 'qqq' : 13, '19' : [1, 2, 3, 4]};
let start = Date.now();
for(let i = 0; i < 500000; i++) {
JSON.parse(JSON.stringify(obj));
}
let stop = Date.now();
console.log("\t JSON: " + (stop - start) + "ms");
start = Date.now();
for(let i = 0; i < 500000; i++) {
msgpack.unpack(msgpack.pack(obj));
}
stop = Date.now();
console.log("\tMsgPack: " + (stop - start) + "ms");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment