mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0023237: OSD_PerfMeter reports wrong (zero) times
Commit details: 1) in OSD_PerfMeter, use static functions of OSD_Chronometer class for time measurements instead of specific code to avoid incorrect results on CentOS (due to wrong valus of CLK_TCK); 2) changed definition of OSD_PerfMeter from .c to .cxx to avoid problems with C-functions; 3) fixed OSD_PerfMeter.h for building on Unix systems; 4) removed platform-specific #defines; 5) added test case for OSD_PerfMeter as bugs fclasses bug23237; 6) Removed DebugTools package (duplicates OSD_PerfMeter) 7) Avoid compiler (GCC) error casting BRepPrimAPI_Make* instances to TopoDS_Shape
This commit is contained in:
@@ -15,9 +15,9 @@ OSD_WNT_BREAK.hxx
|
||||
OSD_signal.cxx
|
||||
OSD_signal_WNT.cxx
|
||||
OSD_ThreadFunction.hxx
|
||||
OSD_PThread.hxx
|
||||
OSD_PThread.hxx
|
||||
OSD_Localizer.cxx
|
||||
OSD_PerfMeter.c
|
||||
OSD_PerfMeter.cxx
|
||||
OSD_PerfMeter.h
|
||||
OSD_PerfMeter.hxx
|
||||
OSD_MAllocHook.cxx
|
||||
|
@@ -38,36 +38,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#include <OSD_Chronometer.hxx>
|
||||
#include <OSD_PerfMeter.h>
|
||||
|
||||
/* ------- Definitions for Windows compiler -------- */
|
||||
#ifdef WNT
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
typedef __int64 PERF_TIME;
|
||||
#define PICK_TIME(_utime) { \
|
||||
FILETIME t1, t2, ktime; \
|
||||
GetThreadTimes (GetCurrentThread(), &t1, &t2, &ktime, (FILETIME *)&(_utime));\
|
||||
}
|
||||
#define GET_SECONDS(_utime) (((double)(_utime))/10000000.)
|
||||
|
||||
/* ------- POSIX Definitions ---------------------- */
|
||||
#else
|
||||
#include <sys/times.h>
|
||||
typedef clock_t PERF_TIME;
|
||||
#define PICK_TIME(_utime) { \
|
||||
struct tms tmbuf; \
|
||||
times (&tmbuf); \
|
||||
(_utime) = tmbuf.tms_utime; \
|
||||
}
|
||||
#define GET_SECONDS(_utime) (((double)(_utime))/CLOCKS_PER_SEC)
|
||||
// #define GET_SECONDS(_utime) (((double)(_utime))/CLK_TCK)
|
||||
#endif
|
||||
|
||||
/*======================================================================
|
||||
DEFINITIONS
|
||||
======================================================================*/
|
||||
|
||||
typedef Standard_Real PERF_TIME;
|
||||
|
||||
#define PICK_TIME(_utime) { \
|
||||
Standard_Real ktime; \
|
||||
OSD_Chronometer::GetThreadCPU(_utime, ktime);\
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char* name; /* identifier */
|
||||
PERF_TIME cumul_time; /* cumulative time */
|
||||
@@ -80,8 +65,8 @@ typedef struct {
|
||||
static t_TimeCounter MeterTable[MAX_METERS];
|
||||
static int nb_meters = 0;
|
||||
|
||||
static int find_meter (const char * const MeterName);
|
||||
static int _perf_init_meter (const char * const MeterName,
|
||||
static int find_meter (const char * const MeterName);
|
||||
static int _perf_init_meter (const char * const MeterName,
|
||||
const int doFind);
|
||||
|
||||
/*======================================================================
|
||||
@@ -229,7 +214,7 @@ int perf_get_meter (const char * const MeterName,
|
||||
|
||||
if (ic >= 0) {
|
||||
if (nb_enter) *nb_enter = MeterTable[ic].nb_enter;
|
||||
if (seconds) *seconds = GET_SECONDS(MeterTable[ic].cumul_time);
|
||||
if (seconds) *seconds = MeterTable[ic].cumul_time;
|
||||
}
|
||||
return ic;
|
||||
}
|
||||
@@ -258,7 +243,7 @@ void perf_print_all_meters (void)
|
||||
t_TimeCounter * const ptc = &MeterTable[i++];
|
||||
|
||||
if (ptc && ptc->nb_enter) {
|
||||
const double secs = GET_SECONDS(ptc->cumul_time);
|
||||
const double secs = ptc->cumul_time;
|
||||
|
||||
if (ptc->start_time)
|
||||
printf ("Warning : meter %s has not been stopped\n", ptc->name);
|
||||
@@ -287,7 +272,7 @@ void perf_close_meter (const char * const MeterName)
|
||||
if (ptc->start_time)
|
||||
printf (" ===> Warning : meter %s has not been stopped\n", ptc->name);
|
||||
printf (" ===> [%s] : %d enters, %9.3f seconds\n",
|
||||
ptc->name, ptc->nb_enter, GET_SECONDS(ptc->cumul_time));
|
||||
ptc->name, ptc->nb_enter, ptc->cumul_time);
|
||||
ptc->cumul_time = 0;
|
||||
ptc->start_time = 0;
|
||||
ptc->nb_enter = 0;
|
||||
@@ -306,7 +291,7 @@ void perf_close_imeter (const int iMeter)
|
||||
if (ptc->start_time)
|
||||
printf (" ===> Warning : meter %s has not been stopped\n", ptc->name);
|
||||
printf (" ===> [%s] : %d enters, %9.3f seconds\n",
|
||||
ptc->name, ptc->nb_enter, GET_SECONDS(ptc->cumul_time));
|
||||
ptc->name, ptc->nb_enter, ptc->cumul_time);
|
||||
ptc->cumul_time = 0;
|
||||
ptc->start_time = 0;
|
||||
ptc->nb_enter = 0;
|
@@ -84,62 +84,50 @@
|
||||
#define PERF_PRINT_ALL
|
||||
#endif
|
||||
|
||||
#ifndef Standard_EXPORT
|
||||
#ifdef WNT
|
||||
#define Standard_EXPORT __declspec( dllexport )
|
||||
#else
|
||||
#define Standard_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Standard_EXPORT int perf_init_meter (const char * const MeterName);
|
||||
Standard_EXPORTEXTERNC int perf_init_meter (const char * const MeterName);
|
||||
/* Creates new counter (if it is absent) identified by
|
||||
MeterName and resets its cumulative value
|
||||
Returns : iMeter if OK, -1 if alloc problem
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_start_meter (const char * const MeterName);
|
||||
Standard_EXPORTEXTERNC int perf_start_meter (const char * const MeterName);
|
||||
/* Forces meter MeterName to begin to count by remembering
|
||||
the current data of timer.
|
||||
Creates new meter if there is no such meter
|
||||
Returns : iMeter if OK, -1 if no such meter and cannot create a new one
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_start_imeter (const int iMeter);
|
||||
Standard_EXPORTEXTERNC int perf_start_imeter (const int iMeter);
|
||||
/* Forces meter with number iMeter to begin count by remembering
|
||||
the current data of timer.
|
||||
Returns : iMeter if OK, -1 if no such meter
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_stop_meter (const char * const MeterName);
|
||||
Standard_EXPORTEXTERNC int perf_stop_meter (const char * const MeterName);
|
||||
/* Forces meter MeterName 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
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_stop_imeter (const int iMeter);
|
||||
Standard_EXPORTEXTERNC int perf_stop_imeter (const int iMeter);
|
||||
/* Forces meter with number iMeter 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
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_tick_meter (const char * const MeterName);
|
||||
Standard_EXPORTEXTERNC int perf_tick_meter (const char * const MeterName);
|
||||
/* 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
|
||||
Returns : iMeter if OK, -1 if no such meter and cannot create a new one
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_tick_imeter (const int iMeter);
|
||||
Standard_EXPORTEXTERNC int perf_tick_imeter (const int iMeter);
|
||||
/* Increments the counter of meter iMeter without changing
|
||||
its state with respect to measurement of time.
|
||||
Returns : iMeter if OK, -1 if no such meter
|
||||
*/
|
||||
|
||||
Standard_EXPORT int perf_get_meter (const char * const MeterName,
|
||||
Standard_EXPORTEXTERNC int perf_get_meter (const char * const MeterName,
|
||||
int * nb_enter,
|
||||
double * seconds);
|
||||
/* Tells the time cumulated by meter MeterName and the number
|
||||
@@ -148,35 +136,31 @@ Standard_EXPORT int perf_get_meter (const char * const MeterName,
|
||||
Returns : iMeter if OK, -1 if no such meter
|
||||
*/
|
||||
|
||||
Standard_EXPORT void perf_close_meter (const char * const MeterName);
|
||||
Standard_EXPORTEXTERNC void perf_close_meter (const char * const MeterName);
|
||||
/* Prints on stdout the cumulated time and the number of enters
|
||||
for the specified meter
|
||||
*/
|
||||
|
||||
Standard_EXPORT void perf_close_imeter (const int iMeter);
|
||||
Standard_EXPORTEXTERNC void perf_close_imeter (const int iMeter);
|
||||
/* Prints on stdout the cumulated time and the number of enters
|
||||
for the specified meter
|
||||
*/
|
||||
|
||||
Standard_EXPORT void perf_print_all_meters (void);
|
||||
Standard_EXPORTEXTERNC void perf_print_all_meters (void);
|
||||
/* Prints on stdout the cumulated time and the number of
|
||||
enters for each alive meter which have the number of enters > 0.
|
||||
Resets all meters
|
||||
*/
|
||||
|
||||
Standard_EXPORT void perf_destroy_all_meters (void);
|
||||
Standard_EXPORTEXTERNC void perf_destroy_all_meters (void);
|
||||
/* Deletes all meters and frees memory
|
||||
*/
|
||||
|
||||
extern void perf_print_and_destroy (void);
|
||||
Standard_EXPORTEXTERNC void perf_print_and_destroy (void);
|
||||
/* ATTENTION !!!
|
||||
This func calls both perf_print_all_meters() and perf_destroy_all_meters()
|
||||
and is called automatically at the end of a program
|
||||
via system call atexit()
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user