I'm writing an application that is very JavaScript heavy (it's pretty much all JavaScript) and it does have a considerable amount of data to iterate through (JSON) and with this it must perform arithmetic certain tasks. Performance is a major consideration of the application. I have introduced Webworkers to help with this and I am trying not to fall back on methods provided by libs like jQuery (like .each()
instead of for
loops). Anyway, here's a simple question...
Within the application I have to apply price changes which will involve alot of numerical processes involving dividing. Baring in mind this will happen thousands and thousands of times would it be better for me to always apply a change by multiplication or a mixture of multiplication and division. For example I can apply a 50% discount by multiplying by 0.5 or dividing by 2.
I was always taught that division is slower than multiplication but I have no real proof of this… has anyone got an opinion on this before I start benchmarking and running test?