Monday, July 25, 2011

[android-developers] Re: CountDownTimer too slow ???

hello Nikolay,

I have updated my code, following your suggestion :

public List<Long> times = new ArrayList<Long>();
CountDownTimer countDown = new CountDownTimer(Integer.MAX_VALUE, 1000)
{
@Override
public void onTick(long millisUntilFinished) {
times.add(System.currentTimeMillis());
}
....
};

and after a while I display the time between two call to "onTick" with
a loop over my list :

for (int i = 1; i < times.size(); i++) {
System.out.println(times.get(i) - times.get(i - 1));
}

And I have something like this :

07-25 18:18:37.281: INFO/System.out(408): 1034
07-25 18:18:37.281: INFO/System.out(408): 1031
07-25 18:18:37.281: INFO/System.out(408): 1017
07-25 18:18:37.281: INFO/System.out(408): 1018
07-25 18:18:37.291: INFO/System.out(408): 1011
07-25 18:18:37.291: INFO/System.out(408): 1019
...

I'm not expecting the precision of an atomic clock, but the error
margin here is huge !

On Jul 25, 8:06 pm, Nikolay Elenkov <nikolay.elen...@gmail.com> wrote:
> On Jul 26, 2011 3:00 AM, "Christophe" <christophe.lebesner...@gmail.com>
> wrote:
>
>
>
> > "Log can be expensive" => I have tried to run the same code with a
> > good old "System.out.println" and the problem is still there.
>
> That goes to the same log buffer, so no change is to be expected. Make a
> list of Long and push currentTimeMillis on each call. Then dump the list to
> log and see what this gives you.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment