Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1792
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Smile 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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Search for constant and show it....
Next Topic: How do I 'check' a Switch control
Goto Forum:
  


Current Time: Sun Aug 24 20:34:34 CEST 2025

Total time taken to generate the page: 0.04380 seconds