Skip to content

Instantly share code, notes, and snippets.

@davidhq
Created December 16, 2019 11:45
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 davidhq/e56be8bbeb03a8ab44038115feb3fbb3 to your computer and use it in GitHub Desktop.
Save davidhq/e56be8bbeb03a8ab44038115feb3fbb3 to your computer and use it in GitHub Desktop.
const v8 = require('v8');
const dmt = require('dmt-bridge');
const { stopwatch, util } = dmt;
//const clone = require('./fast-clone');
const justClone = equire('./utilities/just/collection-clone'),
const state = require(dmt.dmtPath + '/state/program.json');
function cloneJSONStringify(obj) {
return JSON.parse(JSON.stringify(obj));
}
const structuredClone = obj => {
return v8.deserialize(v8.serialize(obj));
};
const timer = stopwatch.start();
//const a = clone(state);
for (let i = 0; i < 1000; i++) {
let a = justClone(state);
//let a = structuredClone(state);
//let a = cloneJSONStringify(state);
}
const duration = stopwatch.stop(timer);
console.log(duration);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment