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 » U++ Library support » U++ Core » What`s the corect way to use TimingInspector?
icon9.gif  What`s the corect way to use TimingInspector? [message #36589] Wed, 13 June 2012 16:00 Go to next message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
I use TimingInspector like this:

TimingInspector tm;

tm.Start();
//Do some function
tm.End();
Cout()<<tm.Dump()<<"\n";

tm.Start();
//Do some function
tm.End();
Cout()<<tm.Dump()<<"\n";

tm.Start();
//Do some function
tm.End();
Cout()<<tm.Dump()<<"\n";

Every time it cout the min time, max time, and the average time.
BUT NO each time ????
waht can i do ? thks!!!
Re: What`s the corect way to use TimingInspector? [message #36590 is a reply to message #36589] Wed, 13 June 2012 17:54 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi akebee

I'm not sure if I understand correctly what are you trying to achieve, but I think there might be a misunderstanding about how TimingInspector works. It is not just a simple stopwatch. It gathers multiple timings of repeated actions (the intervals between Start() and End() calls) and makes up some statistics at the end. The Dump() method is automatically called in destructor, so it dumps the results into the log (see Debug>View the logfile or press Alt+L in TheIDE). If you want to measure times of more than one distinct things, you have to create multiple Timing inspector instances.

Another thing is that TimingInspector is not usually used directly. There is a macro TIMING(label) which simplifies the measurements. The usage is simple, it just measures the times between the line where it is specified and end of current scope (that is till next '}'). E.g.:
#include <Core/Core.h>
using namespace Upp;

void DoSomething(){
    TIMING("timer_in_DoSomething");
    // do something here
}

CONSOLE_APP_MAIN{
    for(int i = 0; i<500; i++)
        DoSomething();
}


Note that timing works in Debug mode only, if you want to profile application build in Optimal mode, you can use RTIMING, the syntax and behavior is the same.

Hope that helps Smile

Best regards,
Honza
icon10.gif  Re: What`s the corect way to use TimingInspector? [message #36593 is a reply to message #36590] Thu, 14 June 2012 07:21 Go to previous messageGo to next message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
yeh
I understand,use the macro,that's very reasonable.
Thanks a lot for your explanation
Re: What`s the corect way to use TimingInspector? [message #36600 is a reply to message #36593] Fri, 15 June 2012 13:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
BTW, perhaps you would want to use TimeStop instead.

Mirek
Re: What`s the corect way to use TimingInspector? [message #36612 is a reply to message #36600] Wed, 20 June 2012 12:59 Go to previous message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
i see,the TimeStop is better Very Happy
Previous Topic: How to mark a class of function is deprecated
Next Topic: [Solved]XML Rpc client will halt when server is not running
Goto Forum:
  


Current Time: Thu Apr 25 06:12:32 CEST 2024

Total time taken to generate the page: 0.05539 seconds