Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is WTK(j2me) use the same compiler as the desktop Java applications?

843810Apr 8 2009 — edited Apr 9 2009
Hello:
I just wrote some tests, and the tests tend to show that WTK cannot change simple functions to "inline", while in desktop java applications,same code can be compiled as "inline". Here are the code:
public static runTest(){ 
 
        long i = 0;
        long j = 0;
        long begin = System.currentTimeMillis();
        int times = 300000;
        for (i = 0; i < times ; i++){
            j = j + i;
        }
        long end = System.currentTimeMillis();
        System.out.println("The result no call is " + (end - begin) );
        begin  = System.currentTimeMillis();
        for (i = 0; i < times ; i++){
            j += set(i);
        }
        end =System.currentTimeMillis();
        System.out.println("The result 1 call is " + (end - begin) );
        
        begin  = System.currentTimeMillis();
        for (i = 0; i < times ; i++){
            j += set2(i);
        }
        end = System.currentTimeMillis();
        System.out.println("The result 2 call is " + (end - begin) );
 }
 
private static long set2(long i) {
	return set(i);
}
 
private static long set(long i) {
        return i;
}
it spends 94ms, 1076ms and 2016ms in simulator.
In desktop app , it spends 2016ms, 2281ms, and 2266ms (cycle times changed to 300,000,000).

I work in eclipse ,and make sure i've checked "Inline finally blocks" check box in both tests.

When building as desktop Java app, i also make sure changed the "compiler compliance level" to 1.3 as in WTK do.

This result confused me. Can someone tell me, are they using different compiler? Or how to explain the result?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2009
Added on Apr 8 2009
4 comments
120 views