NDK clock_gettime problem

Showing 1-7 of 7 messages
NDK clock_gettime problem Mohsen Mohebali 1/30/11 12:34 AM
Hello,

I'm trying to use clock_gettime in my game to calculate elapsed time
between each frame. However, the time I'm getting is not correct. I'm
using the method explained here http://www.guyrutenberg.com/2007/09/22/profiling-code-using-clock_gettime/.

Has anyone been able to successfully utilize "time.h" in NDK?
Re: NDK clock_gettime problem провод 1/30/11 12:45 AM
Hi.
Yes, I do successfully use clock_gettime in many projects and on lots
of phones, for both frame advance and benchmarking purposes.
Could you please be more specific about how its returned time is not correct?

2011/1/30 Mohs3n <moh...@gmail.com>:> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

unk...@googlegroups.com 1/30/11 1:30 AM <This message has been deleted.>
Re: NDK clock_gettime problem Mohsen Mohebali 1/30/11 1:31 AM
I can run the same game on both Windows and Android platform and the
game feels like slow-motion on Android. My game is running in 60fps or
lower. But, the time steps I'm getting from clock_gettime (on Android)
is something from 0.009 to 0.016 seconds, which is clearly lower than
0.016 time steps which I get on average when running in 60fps. Any
idea what I might be doing wrong?
Re: NDK clock_gettime problem провод 1/30/11 1:48 AM
What clock do you use?
If you use CLOCK_PROCESS_CPUTIME_ID or CLOCK_THREAD_CPUTIME_ID, then
you get time your process/thread spent, which is perfect for
benchmarking -- your deltas won't include other processes time, no
matter how much they take. But for the very same reason this is not
the time you'd like to use in your physics and game logic calculations
-- you won't get the real time spent, but somewhat smaller values,
and, therefore, weird-looking game slowdown. I assume that this is
what happens with your application.
For real time related calculations you should use CLOCK_MONOTONIC.

2011/1/30 Mohs3n <moh...@gmail.com>:


> I can run the same game on both Windows and Android platform and the
> game feels like slow-motion on Android. My game is running in 60fps or
> lower. But, the time steps I'm getting from clock_gettime (on Android)
> is something from 0.009 to 0.016 seconds, which is clearly lower that

> 0.016 time steps which I get on average when running in 60fps. Any
> idea what I might be doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

Re: NDK clock_gettime problem Mohsen Mohebali 1/30/11 2:07 AM
I changed cpuid from CLOCK_PROCESS_CPUTIME_ID to CLOCK_MONOTONIC and
that fixed the slow-mo problem. Thanks for your advice.
Re: NDK clock_gettime problem Bill Hsu 1/30/11 6:14 AM
I used to use gettimeofday, but the performance is really bad. clock_gettime works really well. 
Thanks.

On Sun, Jan 30, 2011 at 6:07 PM, Mohs3n <moh...@gmail.com> wrote:
I changed cpuid from CLOCK_PROCESS_CPUTIME_ID to CLOCK_MONOTONIC and
that fixed the slow-mo problem. Thanks for your advice.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.