I'm not sure that I understand your question correctly but if you want
to measure a time interval in "real time" (eg in ms) then go for
android.os.SystemClock.uptimeMillis() or
android.os.SystemClock.elapsedRealtime() not
System.currentTimeMillis()

android.os.SystemClock.uptimeMillis() - milliseconds since the system
was booted. The time is not incremented while the CPU sleeps.
android.os.SystemClock.elapsedRealtime() - milliseconds since the
system was booted including time spent in sleep state.

You should not rely on System.currentTimeMillis(). From the
documentation "The wall clock can be set by the user or the phone
network (see setCurrentTimeMillis(long)), so the time may jump
backwards or forwards unpredictably".

See http://code.google.com/android/reference/android/os/SystemClock.html
for more info.


If you want to measure how long a process is running then go for
android.os.Process.getElapsedCpuTime() - "Returns elapsed milliseconds
of the time this process has run."
If you want to measure how long a Thread has been running, then go for
android.os.SystemClock.currentThreadTimeMillis() - "Returns
milliseconds running in the current thread."
(I haven't tried the last two myself)

Tauno


On Mon, Oct 20, 2008 at 3:53 PM, Andy Quan <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> Anybody knows how to measure time interval for certain process rather
> than CPU elapsed time?
>
> I have noticed there is a class named "android.os.SystemClock", but
> according to its description, it is for CPU timing. And what if I want
> to measure CPU cost of applications like MediaPlayer?
>
> I'd appreciate if there is any comment
>
> Thanks,
> Andy
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to