Home » Community » Newbie corner » time measurement :: RTIMING, TimeStop, GetTickCount
Re: time measurement :: RTIMING, TimeStop, GetTickCount [message #36184 is a reply to message #36180] |
Wed, 09 May 2012 13:34   |
|
Hi Wolfgang,
GetSysTime() returns Time, which works with resolution in seconds. That is not really helpful if you want to track network actions that happen in milliseconds.
What you want to use is GetTickCount() which returns number of milliseconds since epoch. Unfortunatelly, it returns dword value, which means it overflows every 49.7 days. So you might get weird results every now and then On windows this can be fixed by using GetTickCount64(). On other platforms, there is no such function in U++ right now.
Anyway, GetTickCount() should be fine for your purpose. Here is simple example: #include <Core/Core.h>
using namespace Upp;
dword start;
void func_a(){
start = GetTickCount();
};
void func_b(){
LOG("Time: " << (GetTickCount()-start) << " ms");
};
CONSOLE_APP_MAIN{
func_a();
Sleep(1234);
func_b();
}
Just for completeness: *TIMING() macros do something slightly different. They measure how long and how often some block of code is executed. E.g. RTIMING("some_label"){ DoSomething(); } will measure how long it took to execute DoSomething() and how many times it was executed from this exact place. The results are then written in log, together with some statistics.
Best regards,
Honza
|
|
|
 |
|
time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
By: Didier on Wed, 09 May 2012 22:23
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
 |
|
Re: time measurement :: RTIMING, TimeStop, GetTickCount
|
Goto Forum:
Current Time: Sun Aug 24 20:34:34 CEST 2025
Total time taken to generate the page: 0.04380 seconds
|