Skip to content

Instantly share code, notes, and snippets.

@rfdickerson
Last active March 17, 2017 13:56
Show Gist options
  • Select an option

  • Save rfdickerson/e770effdf18173235909dd9a809afd41 to your computer and use it in GitHub Desktop.

Select an option

Save rfdickerson/e770effdf18173235909dd9a809afd41 to your computer and use it in GitHub Desktop.
Benchmark serialization
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
suite.add('mytest', function () {
let a = {
"firstname": "robert",
"lastname": "dickerson",
"date": Date()
};
let b = JSON.stringify(a);
console.log(b);
})
.add('deserialization', function () {
let a = '{"firstname": "robert", "lastname": "dickerson"}';
let b = JSON.parse(a);
console.log(b);
})
.on('complete', function () {
console.log(this.filter().map('stats'));
})
.run({ 'async': true });
@rfdickerson

rfdickerson commented Mar 17, 2017

Copy link
Copy Markdown
Author
[ { moe: 4.754227241024943e-7,
    rme: 4.780532344429988,
    sem: 2.425626143380073e-7,
    deviation: 0.000002128478302528744,
    mean: 0.000009944974531056789,
    sample: 
     [ 0.000008744456861868574,
       0.000012800877961555656,
       0.000009848201311279988,
       0.00001478071881984801,
       0.000008393247951125019,
       0.000012644666815675755,
       0.000007503379824169274,
       0.000007893370734614812,
       0.000012464389360751007,
       0.0000085372710475339,
       0.000012489732826702428,
       0.000008915640441066906,
       0.000011425700938757266,
       0.000008540099389062733,
       0.000011949012069736253,
       0.000008682406943823573,
       0.000011944576069140216,
       0.000008308482789450156,
       0.00000806221069885263,
       0.000012488690657130085,
       0.00000873109029950827,
       0.00001159997645656385,
       0.000008483789897183728,
       0.000012102160780807629,
       0.000008534536283713307,
       0.000012165706005066308,
       0.00000782861496051259,
       0.000007879503352704515,
       0.000012512392787960065,
       0.00000796472254507525,
       0.000009108596334376397,
       0.00001184857174787662,
       0.000008977707942184474,
       0.000011746817612874386,
       0.000012446242139770527,
       0.000008722041424526897,
       0.0000120162139770526,
       0.0000120382710475339,
       0.000009078700938757264,
       0.000011763298912233646,
       0.000008294404410669051,
       0.000012121961704663985,
       0.000008469827149456116,
       0.00000769773968112055,
       0.000007896112352853524,
       0.000012535485620622858,
       0.000008298745194456863,
       0.000008173204440470869,
       0.000007488691849202801,
       0.000012940922813291612,
       0.000007858580688421994,
       0.00001256679585754731,
       0.00000796904693786321,
       0.000008442583221576515,
       0.000012568353747578602,
       0.000008122913574728059,
       0.000007844883921919237,
       0.000012435836835046939,
       0.00000818065549098495,
       0.000012789991208463716,
       0.000007942077931753837,
       0.000007899476978095664,
       0.000007908409029950828,
       0.000012480118313217106,
       0.00000796671226344807,
       0.000008144075845626583,
       0.000012724625093130681,
       0.000007920904187155416,
       0.000008521565638503948,
       0.000014300401728505439,
       0.000011685475488004768,
       0.000007927881239755626,
       0.00000798735479064223,
       0.00001291535836686038,
       0.000008114665325584862,
       0.000008221070034272091,
       0.000008440040977499628 ],
    variance: 4.530419884335644e-12 },
  { moe: 4.286864293413084e-7,
    rme: 1.964282566944867,
    sem: 2.1871756599046347e-7,
    deviation: 0.000002004579603935596,
    mean: 0.000021824071371160355,
    sample: 
     [ 0.00002579407716186253,
       0.000021698406303972368,
       0.00002223406908462867,
       0.000021771679620034544,
       0.00002169305785837651,
       0.000022123087651122625,
       0.000021592616048317515,
       0.000020980148317407563,
       0.000021200725384295802,
       0.00002156161238055671,
       0.00002097020519159456,
       0.00002101571652245571,
       0.000021191391017717348,
       0.0000214729427276473,
       0.000021004843428100535,
       0.000021115126493613514,
       0.000020782473423980223,
       0.000020959880922950143,
       0.00002138386856201071,
       0.000021220610224948876,
       0.000020854049897750513,
       0.0000209892245398773,
       0.00002118829897750511,
       0.000020731705930470348,
       0.000021082092433537833,
       0.000021002278936605316,
       0.000021191910429447853,
       0.000021086512474437626,
       0.000020619237218813908,
       0.000020792065439672802,
       0.000020929926380368096,
       0.000021153310429447853,
       0.000021110503067484662,
       0.000021015332106339467,
       0.000020716779959100204,
       0.00002082273251533742,
       0.000021356559509202455,
       0.000021009085071574644,
       0.000021991845807770963,
       0.000023405611451942742,
       0.000027738557873210634,
       0.000027703308384458078,
       0.00002874662617586912,
       0.000028299942331288343,
       0.000022673676073619632,
       0.000020633834355828223,
       0.000021002148057259713,
       0.000023927692842535788,
       0.000020732357055214724,
       0.000020904441308793455,
       0.000020987587321063397,
       0.000020844513701431493,
       0.00002095604989775051,
       0.00002110215173824131,
       0.000020931536605316974,
       0.000024912152965235172,
       0.000021788692433537834,
       0.000020865860940695296,
       0.00002079767689161554,
       0.000020613728425357875,
       0.000021267669938650306,
       0.00002126843353783231,
       0.000021085705521472392,
       0.00002151813946830266,
       0.000020787336605316973,
       0.000020926715337423315,
       0.000021054743149284256,
       0.000021054004498977507,
       0.000020977265030674845,
       0.00002064446462167689,
       0.000020816333333333336,
       0.000020897300204498975,
       0.000021011588139059304,
       0.00002115459263803681,
       0.000020655865848670757,
       0.000020765801226993862,
       0.000020909851124744376,
       0.000020943961145194273,
       0.000020803044171779143,
       0.00002844127957860616,
       0.000027596507293354945,
       0.0000258360198541329,
       0.000020929888168557535,
       0.000020897348460291736 ],
    variance: 4.01833938851459e-12 } ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment