Multiply vs divide
JavaScript performance comparison
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Multiply |
|
pending… |
Divide |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published
- Revision 3: published
- Revision 5: published
- Revision 7: published by Leo Berdu
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 14: published
1 comment
Browsers are smart, behavior might change based on the condition, see this perf test: http://jsperf.com/multiply-vs-divide/3
And read more about what might be going on this test: http://blog.millermedeiros.com/benchmarking-is-hard/ - TL;DR; JIT and caching are giving misleading results in this case.
I'm not saying you should always use division, I've seen different behavior based on browser and usage. This is probably a "premature optimization" unless you need to do something over an insane amount of data (eg. processing pixels on a large image).
Always profile your code and make sure it does apply to your use case. Also make sure your perf tests aren't biased.
Cheers.