This test is worse than worthless, since the loop will be entirely
eliminated by any sane C compiler, since you don't actually use the
variable 's' in a way that side-effects.

dexopt doesn't eliminate empty loops for various reasons.


On Feb 24, 10:59 am, lianwei <[email protected]> wrote:
> Below is a simple bench between Navive C and Dalvik Java, which is
> collected from Android SDK 1.1.
>
>                                 Dalvik(ms)                  Native(ms)
>  1+2+...1000000           500                             46
>  1*2*...1000000             530                             49
>
> Source code of Dalvik Java:
>         startTimeMillis = System.currentTimeMillis();
>         for (i = 1; i <= 1000000; i++){
>             s += i;  // or s *= i;
>         }
>         endTimeMillis = System.currentTimeMillis();
>
> Source code of native c
>  clock_gettime(CLOCK_MONOTONIC, &tpstart);
>   for (i = 1; i <= 1000000; i++)
>   {
>       s += i; // or s *= i;
>   }
>   clock_gettime(CLOCK_MONOTONIC, &tpend);

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to