I want to test the performance of my js code and I am looking for perf function that John Resig has in his book “Secrets of Javascript Ninja”. Does anyone know about how to create such function or simple function (same as John’s perf) instead of using a testing library?
Here is how his function works:
perf('my test', function(){
// code to test for performance
})
I could not find it on google or book’s code.
There are many simple benchmarking patterns described in an article titled Bulletproof JavaScript benchmarks by Mathias Bynens and John-David Dalton. It’s a good read.
Also for those interested or looking for more then a simple test suite unlike OP, here’s a few: