DEV Community

Discussion on: JavaScript Performance using console.time() & console.timeEnd()

 
varoman profile image
varo manukyan • Edited

Please note, every time you re-run it will produce completely different results, so you can't event say how long it will take a particular function to run.

Unlike console.time(), benchmark allows you to run you suits lots of times, giving your more correct average results.

Or you can test your units with jsperf.com/

Thread Thread
 
dimpiax profile image
Dmytro Pylypenko

Of course, because processor allocates resources differently.
When we talk about measurement for unit tests or for performance function โ€“ time is the range of allowed min/max.

Thread Thread
 
bgadrian profile image
Adrian B.G.

I agree, the dev must know what a framework does, but framework or vanilla, the LOC used to benchmark (like performance or console) would be better to be in separate .js files, which are not bundled into the product.