No, it's just a code segment. If you de-compile the binary you will
find that it's a real loops, not being eliminated .

And in fact, the 1000000 will also be a variable.



On Feb 25, 2:19 am, Daniel Berlin <daniel.ber...@gmail.com> wrote:
> 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 <lianwei.w...@gmail.com> 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 ofnativec
> >  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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to