I often see arguments between Classical (faked via some library), Pseudo-Classical and Prototypal Inheritance mention “efficiency.” However, I’ve never seen any data backing any of this kind of stuff up. Not to mention “efficiency” seems like an ambiguous word when it comes to a coding style, rather than an algorithm.
I’d like to do some tests to “benchmark” some of these patterns and libraries. This seems distinctly different than most algorithm or display benchmarks that I’ve seen in the past. What do you guys think are the important things to test, and what are the best ways to get those numbers reliably.
What I’m thinking currently:
- Speed of instantiation (Time the creation of a few thousand objects
using each pattern w/ identical
functionality) - Memory usage (The only way I can think is to look at my memory in the
task manager… is there a better
way) - Speed of access to internal properties and methods (iteration
timing again) - Speed of copies (iteration timing)
- Lines of code (Peer reviewed best practice following examples with a
count)
Any fallacies, additions, or objections? Anyone seen this data elsewhere?
Thanks!
There are some tests and numbers linked from this blog post.
Also make sure to read this article by John Resig on the accuracy of JavaScript time and how it affects performance benchmarks. If you don’t end up using JSLitmus as Residuum suggested, make sure to still use adaptive test cycles.
Although I agree 100% with darelf’s comment that you should test multiple browsers, you can get detail on memory and cpu usage in Chrome by pressing Shift+Esc.