• Popular Now

• 9
• 10
• 11
• 13
• 9

Archived

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

non win32 equivalent to GetTickCount()

This topic is 5194 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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 on other sites
Modern pmode OSes do not generally allow calling old BIOS functions.
One other alternative is gettimeofday, but that''s not available on Windows.

Share on other sites
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.

Share on other sites
gettimeofday works natively on BSD, Linux, and MacOS X.

Windows is the odd one out. Go figure.

Share on other sites
i wouldnt use clock() its old and supposedly innacurate... plus it doesnt have a very high resolution

Share on other sites
clock() is a little weird, and has a semi-ms resolution. Whereas gettimeofday() has resolution of usec.

Share on other sites
hmmm, ill look into that, thanks

Bungo!

Share on other sites
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...