Created
January 9, 2014 22:02
-
-
Save mraleph/8342886 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function BenchmarkRun() { | |
// Benchmark.prototype.setup goes here | |
obj = { | |
"apples": true, | |
"oranges": true, | |
"pears": true, | |
"pinapples": true, | |
"grapes": true, | |
} | |
array = [ | |
"apples", | |
"oranges", | |
"pears", | |
"pinapples", | |
"grapes", | |
] | |
var start = new Date; | |
for (...) { // do N iterations of test body | |
delete obj.pears | |
} | |
var end = new Date; | |
// Performance is expressed in runs per second: N / ((start - end) / 1000) | |
// But notice how only the first run of the loop actually deletes something | |
// at subsequent iterations property has been already deleted. Which makes | |
// resulting metrics reflect more "how much does it cost to *not* delete a property" | |
// then what you really wanted to measure | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment