Few speed tests about the slow Math.stuff... now using lookup tables instead.


    Dec 19 2011 | 2:20 pm
    Hi,
    I use some giant loops in java, so i made few speed tests, just wanted to share them:
    // CALCULATIONS IN JAVA - SPEED TESTS : // // OK in giant loops... // assignment: ~ 1-5 cycles // addition/substraction: ~ 1-5 cycles // multiplication: ~ 3-6 cycles // // Not so ok... division: ~ 10-20 cycles // // Not ok at all... // Math.pow(...,1 or 2): ~ 55 cycles // Math.exp: ~ 75 cycles // Math.log: ~ 95 cycles // Math.random: ~ 120 cycles // Math.pow(...,anything): ~ 460 cycles ! // Math.pow(...,0.5): ~ 720 cycles !!!
    (Cycles of my I7 processor)
    So after that, i made some look-up tables classes for this Math.stuff, 24 times faster than Math.pow, if you want them, just ask!