开发者

Tickcount and milliseconds in C++

How do I convert from TickCounts to Milliseconds?

this is what I used:

long int before = GetT开发者_开发百科ickCount();
long int after = GetTickCount();

I want the difference of it in seconds.


int seconds = (after - before) /1000;


for more precision, there is also QueryPerformanceCounter()


int seconds = (after - before + 500) / 1000;

or:

double seconds = (after - before) / 1000.0;


GetTickCount() returns the time in milliseconds. so (after - before)/<milli equivalent> should give you time in seconds


I'm not sure what OS/platform you're using, but there should be a call that returns the tick time in milliseconds.

time = after - before * <tick time in milliseconds>;


Edit:

I see that this is a Windows function that returns milliseconds already. The other answers are better.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜