[ https://issues.apache.org/jira/browse/MATH-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13099657#comment-13099657 ]
Sebb commented on MATH-650: --------------------------- In my tests, I found that pre-calculating the data is about twice as fast as calculating it in the static block. That seems a worthwhile improvement to me. Converting the larger preset data tables to IOD gives a massive improvement for routines that don't need any of the IOD tables, and gives corresponding improvements for methods that only use some of the IOD tables. It's also trivial to do, so I did it. Tidying up the code to move the now-unused init code makes only a minor improvement to load times, but is worth it for readability and maintenance. You can do the tests if you want. Math 2.2 is the original FastMath implementation https://repository.apache.org/content/repositories/snapshots/org/apache/commons/commons-math/3.0-SNAPSHOT/ has the jars: commons-math-3.0-20110907.123252-61.jar - preset arrays commons-math-3.0-20110907.222813-62.jar - the IOD code So yes, if an application makes lots of calls the overhead will gradually fade away, but the overhead is very large. In my test I used exp(1000) which uses an IOD table. The repeat time for that is about 5000ns. The first times are approx 40,000,000ns (original) and 8,000,000ns (current). I agree that the lazy init does not help applications that use all the tables. However all applications perform better if the table calculation is done beforehand. > FastMath has static code which slows the first access to FastMath > ----------------------------------------------------------------- > > Key: MATH-650 > URL: https://issues.apache.org/jira/browse/MATH-650 > Project: Commons Math > Issue Type: Improvement > Affects Versions: Nightly Builds > Environment: Android 2.3 (Dalvik VM with JIT) > Reporter: Alexis Robert > Priority: Minor > > Working on an Android application using Orekit, I've discovered that a simple > FastMath.floor() takes about 4 to 5 secs on a 1GHz Nexus One phone (only the > first time it's called). I've launched the Android profiling tool (traceview) > and the problem seems to be linked with the static portion of FastMath code > named "// Initialize tables" > The timing resulted in : > - FastMath.slowexp (40.8%) > - FastMath.expint (39.2%) > \- FastMath.quadmult() (95.6% of expint) > - FastMath.slowlog (18.2%) > Hoping that would help > Thanks! > Alexis Robert -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira