mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0024804: OSD_PerfMeter documentation is broken
This commit is contained in:
@@ -16,146 +16,147 @@
|
|||||||
#ifndef _OSD_PERFMETER_H
|
#ifndef _OSD_PERFMETER_H
|
||||||
#define _OSD_PERFMETER_H
|
#define _OSD_PERFMETER_H
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Macros for convenient and fast usage of meters.
|
* Macros for convenient and fast usage of meters.
|
||||||
Define PERF_ENABLE_METERS to make them available.
|
* Define PERF_ENABLE_METERS to make them available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef PERF_ENABLE_METERS
|
#ifdef PERF_ENABLE_METERS
|
||||||
|
|
||||||
/* PERF_START_METER
|
/**
|
||||||
Forces meter MeterName to begin to count by remembering
|
* @def PERF_START_METER(theMeterName)
|
||||||
the current data of timer.
|
* Forces meter MeterName to begin to count by remembering the current data of timer.
|
||||||
Creates new meter if there is no such meter
|
* Creates new meter if there is no such meter.
|
||||||
*/
|
*/
|
||||||
#define PERF_START_METER(_m_name) { \
|
#define PERF_START_METER(_m_name) { \
|
||||||
static int __iMeter = -1; \
|
static int __iMeter = -1; \
|
||||||
if (__iMeter >= 0) perf_start_imeter (__iMeter); \
|
if (__iMeter >= 0) perf_start_imeter (__iMeter); \
|
||||||
else __iMeter = perf_start_meter (_m_name); \
|
else __iMeter = perf_start_meter (_m_name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PERF_STOP_METER
|
/**
|
||||||
Forces meter MeterName to stop and cumulate the time elapsed
|
* @def PERF_STOP_METER(theMeterName)
|
||||||
since the start
|
* Forces meter MeterName to stop and cumulate the time elapsed since the start.
|
||||||
*/
|
*/
|
||||||
#define PERF_STOP_METER(_m_name) { \
|
#define PERF_STOP_METER(_m_name) { \
|
||||||
static int __iMeter = -1; \
|
static int __iMeter = -1; \
|
||||||
if (__iMeter >= 0) perf_stop_imeter (__iMeter); \
|
if (__iMeter >= 0) perf_stop_imeter (__iMeter); \
|
||||||
else __iMeter = perf_stop_meter (_m_name); \
|
else __iMeter = perf_stop_meter (_m_name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PERF_TICK_METER
|
/**
|
||||||
Increments the counter of meter MeterName without changing
|
* @def PERF_TICK_METER(theMeterName)
|
||||||
its state with respect to measurement of time.
|
* Increments the counter of meter MeterName without changing its state with respect to measurement of time.
|
||||||
Creates new meter if there is no such meter.
|
* Creates new meter if there is no such meter.
|
||||||
It is useful to count the number of enters to a part of code
|
* It is useful to count the number of enters to a part of code without wasting a time to measure CPU time.
|
||||||
without wasting a time to measure CPU time.
|
*/
|
||||||
*/
|
#define PERF_TICK_METER(_m_name) { \
|
||||||
#define PERF_TICK_METER(_m_name) { \
|
static int __iMeter = -1; \
|
||||||
static int __iMeter = -1; \
|
if (__iMeter >= 0) perf_tick_imeter (__iMeter); \
|
||||||
if (__iMeter >= 0) perf_tick_imeter (__iMeter); \
|
else __iMeter = perf_tick_meter (_m_name); \
|
||||||
else __iMeter = perf_tick_meter (_m_name); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PERF_CLOSE_METER
|
/**
|
||||||
Prints out and resets the given meter
|
* @def PERF_CLOSE_METER(theMeterName)
|
||||||
*/
|
* Prints out and resets the given meter.
|
||||||
|
*/
|
||||||
#define PERF_CLOSE_METER(_m_name) perf_close_meter (_m_name);
|
#define PERF_CLOSE_METER(_m_name) perf_close_meter (_m_name);
|
||||||
|
|
||||||
/* PERF_PRINT_ALL
|
/**
|
||||||
Prints all existing meters which have been entered at least once
|
* @def PERF_PRINT_ALL
|
||||||
and resets them
|
* Prints all existing meters which have been entered at least once and resets them.
|
||||||
*/
|
*/
|
||||||
#define PERF_PRINT_ALL { \
|
#define PERF_PRINT_ALL { \
|
||||||
perf_print_all_meters(); \
|
perf_print_all_meters(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define PERF_TICK_METER(_m_name)
|
#define PERF_TICK_METER(_m_name)
|
||||||
#define PERF_START_METER(_m_name)
|
#define PERF_START_METER(_m_name)
|
||||||
#define PERF_STOP_METER(_m_name)
|
#define PERF_STOP_METER(_m_name)
|
||||||
#define PERF_CLOSE_METER(_m_name)
|
#define PERF_CLOSE_METER(_m_name)
|
||||||
#define PERF_PRINT_ALL
|
#define PERF_PRINT_ALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_init_meter (const char * const MeterName);
|
/**
|
||||||
/* Creates new counter (if it is absent) identified by
|
* Creates new counter (if it is absent) identified by theMeterName and resets its cumulative value
|
||||||
MeterName and resets its cumulative value
|
* @return meter global identifier if OK, -1 if alloc problem
|
||||||
Returns : iMeter if OK, -1 if alloc problem
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC int perf_init_meter (const char* const theMeterName);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_start_meter (const char * const MeterName);
|
/**
|
||||||
/* Forces meter MeterName to begin to count by remembering
|
* Forces meter theMeterName to begin to count by remembering the current data of timer.
|
||||||
the current data of timer.
|
* Creates new meter if there is no such meter.
|
||||||
Creates new meter if there is no such meter
|
* @return meter global identifier if OK, -1 if no such meter and cannot create a new one
|
||||||
Returns : iMeter if OK, -1 if no such meter and cannot create a new one
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC int perf_start_meter (const char* const theMeterName);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_start_imeter (const int iMeter);
|
/**
|
||||||
/* Forces meter with number iMeter to begin count by remembering
|
* Forces meter with number theMeterId to begin count by remembering the current data of timer.
|
||||||
the current data of timer.
|
* @return meter global identifier if OK, -1 if no such meter
|
||||||
Returns : iMeter if OK, -1 if no such meter
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC int perf_start_imeter (const int theMeterId);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_stop_meter (const char * const MeterName);
|
/**
|
||||||
/* Forces meter MeterName to stop and cumulate the time elapsed since the start
|
* Forces meter theMeterName to stop and cumulate the time elapsed since the start.
|
||||||
Returns : iMeter if OK, -1 if no such meter or it is has not been started
|
* @return meter global identifier if OK, -1 if no such meter or it is has not been started
|
||||||
*/
|
*/
|
||||||
|
Standard_EXPORTEXTERNC int perf_stop_meter (const char* const theMeterName);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_stop_imeter (const int iMeter);
|
/**
|
||||||
/* Forces meter with number iMeter to stop and cumulate the time
|
* Forces meter with number theMeterId to stop and cumulate the time elapsed since the start.
|
||||||
elapsed since the start.
|
* @return meter global identifier if OK, -1 if no such meter or it is has not been started
|
||||||
Returns : iMeter if OK, -1 if no such meter or it is has not been started
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC int perf_stop_imeter (const int theMeterId);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_tick_meter (const char * const MeterName);
|
/**
|
||||||
/* Increments the counter of meter MeterName without changing
|
* Increments the counter of meter theMeterName without changing its state with respect to measurement of time.
|
||||||
its state with respect to measurement of time.
|
* Creates new meter if there is no such meter.
|
||||||
Creates new meter if there is no such meter
|
* @return meter global identifier if OK, -1 if no such meter and cannot create a new one
|
||||||
Returns : iMeter if OK, -1 if no such meter and cannot create a new one
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC int perf_tick_meter (const char* const theMeterName);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_tick_imeter (const int iMeter);
|
/**
|
||||||
/* Increments the counter of meter iMeter without changing
|
* Increments the counter of meter theMeterId without changing its state with respect to measurement of time.
|
||||||
its state with respect to measurement of time.
|
* @return meter global identifier if OK, -1 if no such meter
|
||||||
Returns : iMeter if OK, -1 if no such meter
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC int perf_tick_imeter (const int theMeterId);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC int perf_get_meter (const char * const MeterName,
|
/**
|
||||||
int * nb_enter,
|
* Tells the time cumulated by meter theMeterName and the number of enters to this meter.
|
||||||
double * seconds);
|
* @param theNbEnter [OUT] number of enters if the pointer != NULL
|
||||||
/* Tells the time cumulated by meter MeterName and the number
|
* @param theSeconds [OUT] seconds if the pointer != NULL
|
||||||
of enters to this meter
|
* @return meter global identifier if OK, -1 if no such meter
|
||||||
Output : *nb_enter, *seconds if the pointers != NULL
|
|
||||||
Returns : iMeter if OK, -1 if no such meter
|
|
||||||
*/
|
*/
|
||||||
|
Standard_EXPORTEXTERNC int perf_get_meter (const char* const theMeterName,
|
||||||
|
int* theNbEnter,
|
||||||
|
double* theSeconds);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC void perf_close_meter (const char * const MeterName);
|
/**
|
||||||
/* Prints on stdout the cumulated time and the number of enters
|
* Prints on stdout the cumulated time and the number of enters for the specified meter.
|
||||||
for the specified meter
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC void perf_close_meter (const char* const theMeterName);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC void perf_close_imeter (const int iMeter);
|
/**
|
||||||
/* Prints on stdout the cumulated time and the number of enters
|
* Prints on stdout the cumulated time and the number of enters for the specified meter.
|
||||||
for the specified meter
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC void perf_close_imeter (const int theMeterId);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC void perf_print_all_meters (void);
|
/**
|
||||||
/* Prints on stdout the cumulated time and the number of
|
* Prints on stdout the cumulated time and the number of enters for each alive meter which have the number of enters > 0.
|
||||||
enters for each alive meter which have the number of enters > 0.
|
* Resets all meters.
|
||||||
Resets all meters
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC void perf_print_all_meters (void);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC void perf_destroy_all_meters (void);
|
/**
|
||||||
/* Deletes all meters and frees memory
|
* Deletes all meters and frees memory.
|
||||||
*/
|
*/
|
||||||
|
Standard_EXPORTEXTERNC void perf_destroy_all_meters (void);
|
||||||
|
|
||||||
Standard_EXPORTEXTERNC void perf_print_and_destroy (void);
|
/**
|
||||||
/* ATTENTION !!!
|
* ATTENTION!!!
|
||||||
This func calls both perf_print_all_meters() and perf_destroy_all_meters()
|
* This func calls both perf_print_all_meters() and perf_destroy_all_meters()
|
||||||
and is called automatically at the end of a program
|
* and is called automatically at the end of a program via system call atexit().
|
||||||
via system call atexit()
|
*/
|
||||||
*/
|
Standard_EXPORTEXTERNC void perf_print_and_destroy (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -18,53 +18,53 @@
|
|||||||
|
|
||||||
#include <OSD_PerfMeter.h>
|
#include <OSD_PerfMeter.h>
|
||||||
|
|
||||||
// This class enables measuring the CPU time between two points of code
|
//! This class enables measuring the CPU time between two points of code execution, regardless of the scope of these points of code.
|
||||||
// execution, regardless of the scope of these points of code. A meter is
|
//! A meter is identified by its name (string). So multiple objects in various places of user code may point to the same meter.
|
||||||
// identified by its name (string of chars). So multiple objects in various
|
//! The results will be printed on stdout upon finish of the program.
|
||||||
// places of user code may point to the same meter. The results will be
|
//! For details see OSD_PerfMeter.h
|
||||||
// printed on stdout upon finish of the program. For details see
|
class OSD_PerfMeter
|
||||||
// OSD_PerfMeter.h
|
{
|
||||||
|
|
||||||
class OSD_PerfMeter {
|
public:
|
||||||
|
|
||||||
public:
|
//! Constructs a void meter (to further call Init and Start)
|
||||||
// ---------- PUBLIC METHODS ----------
|
OSD_PerfMeter() : myIMeter(-1) {}
|
||||||
|
|
||||||
OSD_PerfMeter () : myIMeter(-1) {}
|
//! Constructs and starts (if autoStart is true) the named meter
|
||||||
// constructs a void meter (to further call Init and Start)
|
OSD_PerfMeter (const char* theMeter,
|
||||||
|
const bool theToAutoStart = true)
|
||||||
OSD_PerfMeter (const char* meter, const unsigned autoStart = 1)
|
: myIMeter (perf_get_meter (theMeter, 0, 0))
|
||||||
: myIMeter(perf_get_meter(meter,0,0)) {
|
{
|
||||||
if (myIMeter < 0) myIMeter = perf_init_meter(meter);
|
if (myIMeter < 0) myIMeter = perf_init_meter (theMeter);
|
||||||
if (autoStart) Start();
|
if (theToAutoStart) Start();
|
||||||
}
|
|
||||||
// constructs and starts (if autoStart is true) the named meter
|
|
||||||
|
|
||||||
void Init (const char* meter) {
|
|
||||||
myIMeter = perf_get_meter(meter,0,0);
|
|
||||||
if (myIMeter < 0) myIMeter = perf_init_meter(meter);
|
|
||||||
}
|
}
|
||||||
// prepares the named meter
|
|
||||||
|
|
||||||
void Start () const { perf_start_imeter(myIMeter); }
|
//! Prepares the named meter
|
||||||
// starts the meter
|
void Init (const char* theMeter)
|
||||||
|
{
|
||||||
|
myIMeter = perf_get_meter (theMeter, 0, 0);
|
||||||
|
if (myIMeter < 0) myIMeter = perf_init_meter (theMeter);
|
||||||
|
}
|
||||||
|
|
||||||
void Stop () const { perf_stop_imeter(myIMeter); }
|
//! Starts the meter
|
||||||
// stops the meter
|
void Start() const { perf_start_imeter(myIMeter); }
|
||||||
|
|
||||||
void Tick () const { perf_tick_imeter(myIMeter); }
|
//! Stops the meter
|
||||||
// increments the counter w/o time measurement
|
void Stop() const { perf_stop_imeter(myIMeter); }
|
||||||
|
|
||||||
void Flush () const { perf_close_imeter(myIMeter); }
|
//! Increments the counter w/o time measurement
|
||||||
// outputs the meter data and resets it to initial state
|
void Tick() const { perf_tick_imeter(myIMeter); }
|
||||||
|
|
||||||
virtual ~OSD_PerfMeter () { if (myIMeter >= 0) Stop(); }
|
//! Outputs the meter data and resets it to initial state
|
||||||
// assures stopping upon destruction
|
void Flush() const { perf_close_imeter(myIMeter); }
|
||||||
|
|
||||||
protected:
|
//! Assures stopping upon destruction
|
||||||
// ---------- PROTECTED FIELDS ----------
|
virtual ~OSD_PerfMeter() { if (myIMeter >= 0) Stop(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
int myIMeter;
|
int myIMeter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // OSD_PerfMeter_HeaderFile
|
||||||
|
Reference in New Issue
Block a user