Created
April 26, 2018 18:53
-
-
Save josephwegner/87f157dd8e1ffd6270425ab24f728c90 to your computer and use it in GitHub Desktop.
Generic Object Creation Timing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var JSONStrings = []; | |
for(var i=0; i<74000; i++) { | |
var obj = {}; | |
for(var j=0; j<120; j++) { | |
obj[j] = Math.random(); | |
} | |
JSONStrings.push(JSON.stringify(obj)); | |
} | |
var dataAvailableTime = Date.now(); | |
var finalObjects = []; | |
while(JSONStrings.length) { | |
finalObjects.push(JSON.parse(JSONStrings.shift())); | |
} | |
var finishTime = Date.now(); | |
var runTime = finishTime - dataAvailableTime; | |
console.log('dataAvailableTime', dataAvailableTime); | |
console.log('finishTime', finishTime); | |
console.log('totalDuration', runTime); | |
console.log('average time per obj', (runTime / 74000)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dataAvailableTime 1524768753230 | |
finishTime 1524768758831 | |
totalDuration 5601 | |
average time per obj 0.0756891891891892 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment