Skip to content

Commit

Permalink
add benchmark for getting data from the observed object
Browse files Browse the repository at this point in the history
as requested in #39 (comment)

the benchmark simply serializes the whole object, which triggers the "get" trap on every subtree
  • Loading branch information
warpech committed Jun 24, 2019
1 parent 2d9115a commit f9ab297
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/spec/proxyBenchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,39 @@ function reverseString(str) {

/* ============================= */

{
const suiteName = 'Serialization';

{
const obj = generateBigObjectFixture(100);

suite.add(`${suiteName} (noop)`, function() {
JSON.stringify(obj);
});
}

{
const obj = generateBigObjectFixture(100);
const jsonPatcherProxy = new JSONPatcherProxy(obj);
const observedObj = jsonPatcherProxy.observe(true);

suite.add(`${suiteName} (JSONPatcherProxy)`, function() {
JSON.stringify(observedObj);
});
}

{
const obj = generateBigObjectFixture(100);
const observer = jsonpatch.observe(obj);

suite.add(`${suiteName} (fast-json-patch)`, function() {
JSON.stringify(obj);
});
}
}

/* ============================= */

// if we are in the browser with benchmark < 2.1.2
if (typeof benchmarkReporter !== 'undefined') {
benchmarkReporter(suite);
Expand Down

0 comments on commit f9ab297

Please sign in to comment.