On Sep 20, 11:28 am, Glen Kimsey <gkim...@gmail.com> wrote: > The loading process on a sample (1000+ line) file is abysmally slow > (more than 4 minutes). [...] > > Some possible causes for the slowness: > - Extensive use of parseFloat() > - Creating new StringTokenizer for every line > - Inefficiencies in for() loops (not caching as necessary?) > - Repeated use of the acos() and sqrt() functions
Re-use objects when possible to avoid allocation and construction overhead. For a parser using regular expressions, you avoid the cost of recompiling the RE. acos() and sqrt() are not especially fast; sqrt () in particular, since the G1 lacks floating-point hardware. You can get some sense for where the time is going with the method tracing facility: http://developer.android.com/guide/developing/tools/traceview.html > [...] I could even do something as drastic as > performing this load in a separate app (before distribution) and > somehow exporting the resulting object (KdfAnimation) that could more > easily be picked back up (this would work in C, but I'm doubtful Java > would allow such low-level memory copying). Java does provide a serialization mechanism, but it's not widely loved. :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---