Archived

This topic is now archived and is closed to further replies.

BungoMan85

non win32 equivalent to GetTickCount()

Recommended Posts

BungoMan85    158
im wondering if there is already a function that can retrieve the tick count without using win32, not that i have anything against GetTickCount(), it works wonderfuly for me, but im just wondering if there is something that i could use elsewhere? im assuming since its a win32 api function it''s prolly not gonna work on other platforms... now, i know there is a way to get the tick count in asm using int 1a: mov ah,0 int 1a cx:dx = number of clock ticks since midnight al = nonzero if midnight passed since time last read i know you can put asm in c++ code, but im pretty sure it wont let you use interrupts. would it be worth it to just create a library in asm with a function that just calls that and returns the value in cx or dx and try and use that? Bungo!

Share this post


Link to post
Share on other sites
Deranged    668
you could use SDL with these functs

SDL_GetTicks — Get the number of milliseconds since the SDL library initialization.
SDL_Delay — Wait a specified number of milliseconds before returning.
SDL_AddTimer — Add a timer which will call a callback after the specified number of milliseconds has elapsed.
SDL_RemoveTimer — Remove a timer which was added with SDL_AddTimer.
SDL_SetTimer — Set a callback to run after the specified number of milliseconds has elapsed.


[Mercury Software] [Google!] [ Look I DONT Follow Trends ]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
gettimeofday works natively on BSD, Linux, and MacOS X.

Windows is the odd one out. Go figure.

Share this post


Link to post
Share on other sites
Zahlman    1682
quote:
Original post by jperalta
clock() is a little weird, and has a semi-ms resolution. Whereas gettimeofday() has resolution of usec.


I don''t think I will ever understand why the function that sounds like it''s being used to read the system clock (not to mention other functions and interfaces like the interval timers, which apparently are specifically intended to be used for benchmarking) is less precise than the one that sounds like it''s intended to tell humans what time it is.

Bit me during my undergrad thesis work when I needed that usec timing. All else had failed, when my supervisor had the idea...

Share this post


Link to post
Share on other sites