In this article test application listed below was written for J2ME devices and all test results
was taken from running application on a real Nokia mobile phone. Applying this optimisation
on any other platform or any different language may take effect on the results.
You can try to use optimised loop definitions in PHP, Bash, C++ or any
synthax-compatible language, write some tests and check the results.
importjavax.microedition.midlet.*;publicclassApplicationextendsMIDlet{publicvoidstartApp(){longstart,end;/* Обычный цикл */start=System.currentTimeMillis();for(inti=0;i<9000000;i++){/* do something */}end=System.currentTimeMillis();System.out.println("Normal loop: "+(end-start)+" milliseconds");/* Оптимизированный цикл */start=System.currentTimeMillis();for(inti=8999999;i>=0;i--){/* do something */}end=System.currentTimeMillis();System.out.println("Optimized loop: "+(end-start)+" milliseconds");System.out.println("\n");destroyApp(true);}publicvoidpauseApp(){notifyPaused();}publicvoiddestroyApp(booleanunconditional){notifyDestroyed();}}