forked from speed-dreams/speed-dreams-code
Made tgf::profiler tool available under Windows too ; better service names for tgf::profiler and schedulespy ; empty binary footprint for profiler and schedulespy if not enabled at compile time
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2532 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 88bef947ee7d161db105e19c86f69ab688c4f4fa Former-commit-id: 7db062224920ac97d93aad73ca0c7a148e765372
This commit is contained in:
parent
acf27a42d6
commit
51e302cfb1
7 changed files with 141 additions and 118 deletions
|
@ -28,8 +28,8 @@
|
||||||
static void
|
static void
|
||||||
endofprog(void * /* dummy */)
|
endofprog(void * /* dummy */)
|
||||||
{
|
{
|
||||||
STOP_ACTIVE_PROFILES();
|
GfProfStopActiveProfiles();
|
||||||
PRINT_PROFILE();
|
GfProfPrintReport();
|
||||||
GfScrShutdown();
|
GfScrShutdown();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1085,7 +1085,7 @@ ReOneStep(double deltaTimeIncrement)
|
||||||
ReInfo->_reLastTime = 0.0;
|
ReInfo->_reLastTime = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
START_PROFILE("rbDrive*");
|
GfProfStartProfile("rbDrive*");
|
||||||
if ((s->currentTime - ReInfo->_reLastTime) >= RCM_MAX_DT_ROBOTS) {
|
if ((s->currentTime - ReInfo->_reLastTime) >= RCM_MAX_DT_ROBOTS) {
|
||||||
SignalEvent(Bots);
|
SignalEvent(Bots);
|
||||||
s->deltaTime = s->currentTime - ReInfo->_reLastTime;
|
s->deltaTime = s->currentTime - ReInfo->_reLastTime;
|
||||||
|
@ -1104,7 +1104,7 @@ ReOneStep(double deltaTimeIncrement)
|
||||||
}
|
}
|
||||||
ReInfo->_reLastTime = s->currentTime;
|
ReInfo->_reLastTime = s->currentTime;
|
||||||
}
|
}
|
||||||
STOP_PROFILE("rbDrive*");
|
GfProfStopProfile("rbDrive*");
|
||||||
|
|
||||||
|
|
||||||
if (GetNetwork())
|
if (GetNetwork())
|
||||||
|
@ -1113,12 +1113,12 @@ ReOneStep(double deltaTimeIncrement)
|
||||||
}
|
}
|
||||||
|
|
||||||
SignalEvent(Simu);
|
SignalEvent(Simu);
|
||||||
START_PROFILE("_reSimItf.update*");
|
GfProfStartProfile("_reSimItf.update*");
|
||||||
ReInfo->_reSimItf.update(s, deltaTimeIncrement, -1);
|
ReInfo->_reSimItf.update(s, deltaTimeIncrement, -1);
|
||||||
for (i = 0; i < s->_ncars; i++) {
|
for (i = 0; i < s->_ncars; i++) {
|
||||||
ReManage(s->cars[i]);
|
ReManage(s->cars[i]);
|
||||||
}
|
}
|
||||||
STOP_PROFILE("_reSimItf.update*");
|
GfProfStopProfile("_reSimItf.update*");
|
||||||
|
|
||||||
ReSortCars();
|
ReSortCars();
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ void ReInitUpdater()
|
||||||
if (!situationUpdater)
|
if (!situationUpdater)
|
||||||
situationUpdater = new reSituationUpdater(ReInfo);
|
situationUpdater = new reSituationUpdater(ReInfo);
|
||||||
|
|
||||||
GfssConfigureEventLog("graphics", 10000, 0.0);
|
GfSchedConfigureEventLog("graphics", 10000, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReInitCarGraphics(void)
|
void ReInitCarGraphics(void)
|
||||||
|
@ -1156,7 +1156,7 @@ void
|
||||||
ReStart(void)
|
ReStart(void)
|
||||||
{
|
{
|
||||||
#ifdef ReMultiThreaded
|
#ifdef ReMultiThreaded
|
||||||
GfssBeginSession();
|
GfSchedBeginSession();
|
||||||
situationUpdater->start();
|
situationUpdater->start();
|
||||||
#else // ReMultiThreaded
|
#else // ReMultiThreaded
|
||||||
ReInfo->_reRunning = 1;
|
ReInfo->_reRunning = 1;
|
||||||
|
@ -1169,7 +1169,7 @@ ReStop(void)
|
||||||
{
|
{
|
||||||
#ifdef ReMultiThreaded
|
#ifdef ReMultiThreaded
|
||||||
situationUpdater->stop();
|
situationUpdater->stop();
|
||||||
GfssEndSession();
|
GfSchedEndSession();
|
||||||
#else
|
#else
|
||||||
ReInfo->_reRunning = 0;
|
ReInfo->_reRunning = 0;
|
||||||
#endif // ReMultiThreaded
|
#endif // ReMultiThreaded
|
||||||
|
@ -1184,7 +1184,7 @@ void ReShutdownUpdater()
|
||||||
delete situationUpdater;
|
delete situationUpdater;
|
||||||
situationUpdater = 0;
|
situationUpdater = 0;
|
||||||
}
|
}
|
||||||
GfssPrintReport("schedule.csv", 1.0e-4);
|
GfSchedPrintReport("schedule.csv", 1.0e-4);
|
||||||
}
|
}
|
||||||
#endif // ReMultiThreaded
|
#endif // ReMultiThreaded
|
||||||
|
|
||||||
|
@ -1220,17 +1220,17 @@ ReUpdate(void)
|
||||||
tRmMovieCapture *capture;
|
tRmMovieCapture *capture;
|
||||||
|
|
||||||
|
|
||||||
START_PROFILE("ReUpdate");
|
GfProfStartProfile("ReUpdate");
|
||||||
ReInfo->_refreshDisplay = 0;
|
ReInfo->_refreshDisplay = 0;
|
||||||
switch (ReInfo->_displayMode) {
|
switch (ReInfo->_displayMode) {
|
||||||
case RM_DISP_MODE_NORMAL:
|
case RM_DISP_MODE_NORMAL:
|
||||||
t = GfTimeClock();
|
t = GfTimeClock();
|
||||||
|
|
||||||
START_PROFILE("ReOneStep*");
|
GfProfStartProfile("ReOneStep*");
|
||||||
while (ReInfo->_reRunning && ((t - ReInfo->_reCurTime) > RCM_MAX_DT_SIMU)) {
|
while (ReInfo->_reRunning && ((t - ReInfo->_reCurTime) > RCM_MAX_DT_SIMU)) {
|
||||||
ReOneStep(RCM_MAX_DT_SIMU);
|
ReOneStep(RCM_MAX_DT_SIMU);
|
||||||
}
|
}
|
||||||
STOP_PROFILE("ReOneStep*");
|
GfProfStopProfile("ReOneStep*");
|
||||||
|
|
||||||
//Send car physics to network if needed
|
//Send car physics to network if needed
|
||||||
if (GetNetwork())
|
if (GetNetwork())
|
||||||
|
@ -1279,7 +1279,7 @@ ReUpdate(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
STOP_PROFILE("ReUpdate");
|
GfProfStopProfile("ReUpdate");
|
||||||
|
|
||||||
return RM_ASYNC;
|
return RM_ASYNC;
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1363,7 @@ int reSituationUpdater::threadLoop()
|
||||||
|
|
||||||
realTime = GfTimeClock();
|
realTime = GfTimeClock();
|
||||||
|
|
||||||
START_PROFILE("ReOneStep*");
|
GfProfStartProfile("ReOneStep*");
|
||||||
|
|
||||||
while (_pCurrReInfo->_reRunning
|
while (_pCurrReInfo->_reRunning
|
||||||
&& ((realTime - _pCurrReInfo->_reCurTime) > RCM_MAX_DT_SIMU))
|
&& ((realTime - _pCurrReInfo->_reCurTime) > RCM_MAX_DT_SIMU))
|
||||||
|
@ -1372,7 +1372,7 @@ int reSituationUpdater::threadLoop()
|
||||||
ReOneStep(RCM_MAX_DT_SIMU);
|
ReOneStep(RCM_MAX_DT_SIMU);
|
||||||
}
|
}
|
||||||
|
|
||||||
STOP_PROFILE("ReOneStep*");
|
GfProfStopProfile("ReOneStep*");
|
||||||
|
|
||||||
// Send car physics to network if needed
|
// Send car physics to network if needed
|
||||||
if (GetNetwork())
|
if (GetNetwork())
|
||||||
|
@ -1802,13 +1802,13 @@ void reSituationUpdater::computeCurrentStep()
|
||||||
{
|
{
|
||||||
const double t = GfTimeClock();
|
const double t = GfTimeClock();
|
||||||
|
|
||||||
START_PROFILE("ReOneStep*");
|
GfProfStartProfile("ReOneStep*");
|
||||||
|
|
||||||
while (_pCurrReInfo->_reRunning && ((t - _pCurrReInfo->_reCurTime) > RCM_MAX_DT_SIMU))
|
while (_pCurrReInfo->_reRunning && ((t - _pCurrReInfo->_reCurTime) > RCM_MAX_DT_SIMU))
|
||||||
|
|
||||||
ReOneStep(RCM_MAX_DT_SIMU);
|
ReOneStep(RCM_MAX_DT_SIMU);
|
||||||
|
|
||||||
STOP_PROFILE("ReOneStep*");
|
GfProfStopProfile("ReOneStep*");
|
||||||
|
|
||||||
// Send car physics to network if needed
|
// Send car physics to network if needed
|
||||||
if (GetNetwork())
|
if (GetNetwork())
|
||||||
|
@ -1821,7 +1821,7 @@ ReUpdate(void)
|
||||||
{
|
{
|
||||||
tRmInfo* pPrevReInfo;
|
tRmInfo* pPrevReInfo;
|
||||||
|
|
||||||
START_PROFILE("ReUpdate");
|
GfProfStartProfile("ReUpdate");
|
||||||
ReInfo->_refreshDisplay = 0;
|
ReInfo->_refreshDisplay = 0;
|
||||||
switch (ReInfo->_displayMode)
|
switch (ReInfo->_displayMode)
|
||||||
{
|
{
|
||||||
|
@ -1848,9 +1848,9 @@ ReUpdate(void)
|
||||||
|
|
||||||
SignalEvent(Graph);
|
SignalEvent(Graph);
|
||||||
|
|
||||||
GfssBeginEvent("graphics");
|
GfSchedBeginEvent("graphics");
|
||||||
pPrevReInfo->_reGraphicItf.refresh(pPrevReInfo->s);
|
pPrevReInfo->_reGraphicItf.refresh(pPrevReInfo->s);
|
||||||
GfssEndEvent("graphics");
|
GfSchedEndEvent("graphics");
|
||||||
|
|
||||||
GfelPostRedisplay(); /* Callback -> reDisplay */
|
GfelPostRedisplay(); /* Callback -> reDisplay */
|
||||||
break;
|
break;
|
||||||
|
@ -1897,7 +1897,7 @@ ReUpdate(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
STOP_PROFILE("ReUpdate");
|
GfProfStopProfile("ReUpdate");
|
||||||
|
|
||||||
return RM_ASYNC;
|
return RM_ASYNC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,50 @@
|
||||||
|
|
||||||
#ifdef PROFILER
|
#ifdef PROFILER
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "tgf.h"
|
#include "tgf.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ProfileInstance {
|
||||||
|
public:
|
||||||
|
ProfileInstance(const char * pname);
|
||||||
|
~ProfileInstance();
|
||||||
|
char name[256];
|
||||||
|
int calls;
|
||||||
|
int openCalls;
|
||||||
|
double totalTime;
|
||||||
|
double addTime;
|
||||||
|
double subTime;
|
||||||
|
double tmpStart;
|
||||||
|
std::map<ProfileInstance *, void *> mapChildren;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Profiler {
|
||||||
|
protected:
|
||||||
|
Profiler();
|
||||||
|
public:
|
||||||
|
~Profiler();
|
||||||
|
static Profiler * getInstance();
|
||||||
|
void startProfile(const char * pname);
|
||||||
|
void stopProfile();
|
||||||
|
void stopActiveProfiles();
|
||||||
|
void printReport();
|
||||||
|
private:
|
||||||
|
static Profiler * profiler;
|
||||||
|
ProfileInstance * curProfile;
|
||||||
|
double fStartTime;
|
||||||
|
std::vector<ProfileInstance *> vecProfiles;
|
||||||
|
std::vector<ProfileInstance *> stkProfiles;
|
||||||
|
std::map<ProfileInstance *, void *> mapWarning;
|
||||||
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ProfileInstance::ProfileInstance(const char * pname) {
|
ProfileInstance::ProfileInstance(const char * pname) {
|
||||||
|
@ -123,7 +158,7 @@ bool instanceLess(const ProfileInstance * p1, const ProfileInstance * p2) {
|
||||||
|
|
||||||
#define TRUNC(a) ( (a) < 0.001 ? 0.0 : (a) )
|
#define TRUNC(a) ( (a) < 0.001 ? 0.0 : (a) )
|
||||||
|
|
||||||
void Profiler::printProfile() {
|
void Profiler::printReport() {
|
||||||
double total = GfTimeClock() - fStartTime;
|
double total = GfTimeClock() - fStartTime;
|
||||||
std::cerr << "****************** PROFILE ***********************" << std::endl;
|
std::cerr << "****************** PROFILE ***********************" << std::endl;
|
||||||
std::cerr << "Total : " << total << std::endl;
|
std::cerr << "Total : " << total << std::endl;
|
||||||
|
@ -163,4 +198,27 @@ void Profiler::printProfile() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// C interface functions //-----------------------------------------------------------------
|
||||||
|
|
||||||
|
void GfProfStartProfile(const char* pszName)
|
||||||
|
{
|
||||||
|
Profiler::getInstance()->startProfile(pszName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GfProfStopProfile(const char* pszName)
|
||||||
|
{
|
||||||
|
// TODO: Why pszName if not used ????
|
||||||
|
Profiler::getInstance()->stopProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GfProfStopActiveProfiles()
|
||||||
|
{
|
||||||
|
Profiler::getInstance()->stopActiveProfiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GfProfPrintReport()
|
||||||
|
{
|
||||||
|
Profiler::getInstance()->printReport();
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* PROFILER */
|
#endif /* PROFILER */
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
file : schedulespy.cpp
|
file : schedulespy.cpp
|
||||||
author : Jean-Philippe Meuret (jpmeuret@free.fr)
|
author : Jean-Philippe Meuret (jpmeuret@free.fr)
|
||||||
|
|
||||||
A tool to study the way some special code sections (named "events)
|
A tool to study the way some special code sections (named "events" here)
|
||||||
in the program are actually scheduled at a fine grain level.
|
in the program are actually scheduled at a fine grain level.
|
||||||
Absolute time and duration are logged in memory each time declared sections
|
Absolute time and duration are logged in memory each time declared sections
|
||||||
are executed.
|
are executed.
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifdef SCHEDULE_SPY
|
||||||
|
|
||||||
//#include <iostream>
|
//#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -27,8 +29,6 @@
|
||||||
#include "tgf.h"
|
#include "tgf.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
|
|
||||||
class GfScheduleEventLog
|
class GfScheduleEventLog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -176,9 +176,6 @@ void GfScheduleSpy::printReport(const char* pszFileName, double fTimeResolution)
|
||||||
// Not yet implemented.
|
// Not yet implemented.
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
|
|
||||||
|
|
||||||
// C interface functions //-----------------------------------------------------------------
|
// C interface functions //-----------------------------------------------------------------
|
||||||
|
|
||||||
/* Configure an event log before using it (can be called more than once to change settings)
|
/* Configure an event log before using it (can be called more than once to change settings)
|
||||||
|
@ -186,53 +183,43 @@ void GfScheduleSpy::printReport(const char* pszFileName, double fTimeResolution)
|
||||||
\param pszLogName Name/id
|
\param pszLogName Name/id
|
||||||
\param nMaxEvents Maximum number of events to be logged (other ignored)
|
\param nMaxEvents Maximum number of events to be logged (other ignored)
|
||||||
\param dIgnoreDelay Delay (s) before taking Begin/EndEvent into account (from BeginSession time) */
|
\param dIgnoreDelay Delay (s) before taking Begin/EndEvent into account (from BeginSession time) */
|
||||||
void GfssConfigureEventLog(const char* pszLogName, unsigned nMaxEvents, double dIgnoreDelay)
|
void GfSchedConfigureEventLog(const char* pszLogName, unsigned nMaxEvents, double dIgnoreDelay)
|
||||||
{
|
{
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
GfScheduleSpy::self()->configureEventLog(pszLogName, nMaxEvents, dIgnoreDelay);
|
GfScheduleSpy::self()->configureEventLog(pszLogName, nMaxEvents, dIgnoreDelay);
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start a new spying session
|
/* Start a new spying session
|
||||||
@ingroup schedulespy
|
@ingroup schedulespy
|
||||||
\precondition All event logs must be configured at least once before) */
|
\precondition All event logs must be configured at least once before) */
|
||||||
void GfssBeginSession()
|
void GfSchedBeginSession()
|
||||||
{
|
{
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
GfScheduleSpy::self()->beginSession();
|
GfScheduleSpy::self()->beginSession();
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Log the beginning of an event (enter the associated code section)
|
/* Log the beginning of an event (enter the associated code section)
|
||||||
@ingroup schedulespy
|
@ingroup schedulespy
|
||||||
\precondition BeginSession
|
\precondition BeginSession
|
||||||
\param pszLogName Name/id */
|
\param pszLogName Name/id */
|
||||||
void GfssBeginEvent(const char* pszLogName)
|
void GfSchedBeginEvent(const char* pszLogName)
|
||||||
{
|
{
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
GfScheduleSpy::self()->beginEvent(pszLogName);
|
GfScheduleSpy::self()->beginEvent(pszLogName);
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Log the end of an event (exit from the associated code section)
|
/* Log the end of an event (exit from the associated code section)
|
||||||
@ingroup schedulespy
|
@ingroup schedulespy
|
||||||
\precondition BeginEvent(pszLogName)
|
\precondition BeginEvent(pszLogName)
|
||||||
\param pszLogName Name/id */
|
\param pszLogName Name/id */
|
||||||
void GfssEndEvent(const char* pszLogName)
|
void GfSchedEndEvent(const char* pszLogName)
|
||||||
{
|
{
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
GfScheduleSpy::self()->endEvent(pszLogName);
|
GfScheduleSpy::self()->endEvent(pszLogName);
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate the current spying session
|
/* Terminate the current spying session
|
||||||
@ingroup schedulespy
|
@ingroup schedulespy
|
||||||
\precondition BeginSession */
|
\precondition BeginSession */
|
||||||
void GfssEndSession()
|
void GfSchedEndSession()
|
||||||
{
|
{
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
GfScheduleSpy::self()->endSession();
|
GfScheduleSpy::self()->endSession();
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print a table log (2 columns for each event log : start time and duration)
|
/* Print a table log (2 columns for each event log : start time and duration)
|
||||||
|
@ -241,9 +228,9 @@ void GfssEndSession()
|
||||||
\param fTimeResolution Time resolution to use
|
\param fTimeResolution Time resolution to use
|
||||||
(minimum delay between 2 event starts)
|
(minimum delay between 2 event starts)
|
||||||
\precondition EndSession */
|
\precondition EndSession */
|
||||||
void GfssPrintReport(const char* pszFileName, double fTimeResolution)
|
void GfSchedPrintReport(const char* pszFileName, double fTimeResolution)
|
||||||
{
|
{
|
||||||
#ifdef SCHEDULE_SPY
|
|
||||||
GfScheduleSpy::self()->printReport(pszFileName, fTimeResolution);
|
GfScheduleSpy::self()->printReport(pszFileName, fTimeResolution);
|
||||||
#endif // SCHEDULE_SPY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // SCHEDULE_SPY
|
||||||
|
|
|
@ -606,55 +606,20 @@ struct { \
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
#ifdef PROFILER
|
#ifdef PROFILER
|
||||||
|
|
||||||
#include <vector>
|
TGF_API void GfProfStartProfile(const char* pszName);
|
||||||
#include <map>
|
TGF_API void GfProfStopProfile(const char* pszName);
|
||||||
|
TGF_API void GfProfStopActiveProfiles();
|
||||||
|
TGF_API void GfProfPrintReport();
|
||||||
|
|
||||||
#define START_PROFILE(name) Profiler::getInstance()->startProfile(name)
|
#else // PROFILER
|
||||||
#define STOP_PROFILE(name) Profiler::getInstance()->stopProfile()
|
|
||||||
#define STOP_ACTIVE_PROFILES() Profiler::getInstance()->stopActiveProfiles()
|
|
||||||
#define PRINT_PROFILE() Profiler::getInstance()->printProfile()
|
|
||||||
|
|
||||||
class ProfileInstance {
|
#define GfProfStartProfile(pszName)
|
||||||
public:
|
#define GfProfStopProfile(pszName)
|
||||||
ProfileInstance(const char * pname);
|
#define GfProfStopActiveProfiles()
|
||||||
~ProfileInstance();
|
#define GfProfPrintReport()
|
||||||
char name[256];
|
|
||||||
int calls;
|
|
||||||
int openCalls;
|
|
||||||
double totalTime;
|
|
||||||
double addTime;
|
|
||||||
double subTime;
|
|
||||||
double tmpStart;
|
|
||||||
std::map<ProfileInstance *, void *> mapChildren;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Profiler {
|
#endif // PROFILER
|
||||||
protected:
|
|
||||||
Profiler();
|
|
||||||
public:
|
|
||||||
~Profiler();
|
|
||||||
static Profiler * getInstance();
|
|
||||||
void startProfile(const char * pname);
|
|
||||||
void stopProfile();
|
|
||||||
void stopActiveProfiles();
|
|
||||||
void printProfile();
|
|
||||||
private:
|
|
||||||
static Profiler * profiler;
|
|
||||||
ProfileInstance * curProfile;
|
|
||||||
double fStartTime;
|
|
||||||
std::vector<ProfileInstance *> vecProfiles;
|
|
||||||
std::vector<ProfileInstance *> stkProfiles;
|
|
||||||
std::map<ProfileInstance *, void *> mapWarning;
|
|
||||||
};
|
|
||||||
|
|
||||||
#else /* PROFILER */
|
|
||||||
|
|
||||||
#define START_PROFILE(a)
|
|
||||||
#define STOP_PROFILE(a)
|
|
||||||
#define STOP_ACTIVE_PROFILES()
|
|
||||||
#define PRINT_PROFILE()
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**************************************************************
|
/**************************************************************
|
||||||
* ScheduleSpy definitions. *
|
* ScheduleSpy definitions. *
|
||||||
|
@ -664,12 +629,25 @@ class Profiler {
|
||||||
* at a fine grain level (see schedulespy.cpp for details). *
|
* at a fine grain level (see schedulespy.cpp for details). *
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
TGF_API void GfssConfigureEventLog(const char* pszLogName, unsigned nMaxEvents, double dIgnoreDelay);
|
#ifdef SCHEDULE_SPY
|
||||||
TGF_API void GfssBeginSession();
|
|
||||||
TGF_API void GfssBeginEvent(const char* pszLogName);
|
TGF_API void GfSchedConfigureEventLog(const char* pszLogName, unsigned nMaxEvents, double dIgnoreDelay);
|
||||||
TGF_API void GfssEndEvent(const char* pszLogName);
|
TGF_API void GfSchedBeginSession();
|
||||||
TGF_API void GfssEndSession();
|
TGF_API void GfSchedBeginEvent(const char* pszLogName);
|
||||||
TGF_API void GfssPrintReport(const char* pszFileName, double fTimeResolution);
|
TGF_API void GfSchedEndEvent(const char* pszLogName);
|
||||||
|
TGF_API void GfSchedEndSession();
|
||||||
|
TGF_API void GfSchedPrintReport(const char* pszFileName, double fTimeResolution);
|
||||||
|
|
||||||
|
#else // SCHEDULE_SPY
|
||||||
|
|
||||||
|
#define GfSchedConfigureEventLog(pszLogName, nMaxEvents, dIgnoreDelay)
|
||||||
|
#define GfSchedBeginSession()
|
||||||
|
#define GfSchedBeginEvent(pszLogName)
|
||||||
|
#define GfSchedEndEvent(pszLogName)
|
||||||
|
#define GfSchedEndSession()
|
||||||
|
#define GfSchedPrintReport(pszFileName, fTimeResolution)
|
||||||
|
|
||||||
|
#endif // SCHEDULE_SPY
|
||||||
|
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
|
@ -303,7 +303,7 @@ refresh(tSituation *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
START_PROFILE("refresh");
|
GfProfStartProfile("refresh");
|
||||||
|
|
||||||
nFrame++;
|
nFrame++;
|
||||||
nTotalFrame++;
|
nTotalFrame++;
|
||||||
|
@ -319,14 +319,14 @@ refresh(tSituation *s)
|
||||||
|
|
||||||
TRACE_GL("refresh: start");
|
TRACE_GL("refresh: start");
|
||||||
|
|
||||||
START_PROFILE("grRefreshSound*");
|
GfProfStartProfile("grRefreshSound*");
|
||||||
grRefreshSound(s, grScreens[0]->getCurCamera());
|
grRefreshSound(s, grScreens[0]->getCurCamera());
|
||||||
STOP_PROFILE("grRefreshSound*");
|
GfProfStopProfile("grRefreshSound*");
|
||||||
|
|
||||||
START_PROFILE("grDrawBackground/glClear");
|
GfProfStartProfile("grDrawBackground/glClear");
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
STOP_PROFILE("grDrawBackground/glClear");
|
GfProfStopProfile("grDrawBackground/glClear");
|
||||||
|
|
||||||
for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
|
for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
|
||||||
grScreens[i]->update(s, grFps);
|
grScreens[i]->update(s, grFps);
|
||||||
|
@ -335,7 +335,7 @@ refresh(tSituation *s)
|
||||||
grUpdateSmoke(s->currentTime);
|
grUpdateSmoke(s->currentTime);
|
||||||
grTrackLightUpdate(s);
|
grTrackLightUpdate(s);
|
||||||
|
|
||||||
STOP_PROFILE("refresh");
|
GfProfStopProfile("refresh");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,9 +223,9 @@ void cGrScreen::camDraw(tSituation *s)
|
||||||
|
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
|
|
||||||
START_PROFILE("dispCam->update*");
|
GfProfStartProfile("dispCam->update*");
|
||||||
dispCam->update(curCar, s);
|
dispCam->update(curCar, s);
|
||||||
STOP_PROFILE("dispCam->update*");
|
GfProfStopProfile("dispCam->update*");
|
||||||
|
|
||||||
if (dispCam->getDrawBackground()) {
|
if (dispCam->getDrawBackground()) {
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
|
@ -235,11 +235,11 @@ void cGrScreen::camDraw(tSituation *s)
|
||||||
}
|
}
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
START_PROFILE("dispCam->action*");
|
GfProfStartProfile("dispCam->action*");
|
||||||
dispCam->action();
|
dispCam->action();
|
||||||
STOP_PROFILE("dispCam->action*");
|
GfProfStopProfile("dispCam->action*");
|
||||||
|
|
||||||
START_PROFILE("grDrawCar*");
|
GfProfStartProfile("grDrawCar*");
|
||||||
glFogf(GL_FOG_START, dispCam->getFogStart());
|
glFogf(GL_FOG_START, dispCam->getFogStart());
|
||||||
glFogf(GL_FOG_END, dispCam->getFogEnd());
|
glFogf(GL_FOG_END, dispCam->getFogEnd());
|
||||||
glEnable(GL_FOG);
|
glEnable(GL_FOG);
|
||||||
|
@ -251,9 +251,9 @@ void cGrScreen::camDraw(tSituation *s)
|
||||||
for (i = 0; i < s->_ncars; i++) {
|
for (i = 0; i < s->_ncars; i++) {
|
||||||
grDrawCar(s, cars[i], curCar, dispCam->getDrawCurrent(), dispCam->getDrawDriver(), s->currentTime, dispCam);
|
grDrawCar(s, cars[i], curCar, dispCam->getDrawCurrent(), dispCam->getDrawDriver(), s->currentTime, dispCam);
|
||||||
}
|
}
|
||||||
STOP_PROFILE("grDrawCar*");
|
GfProfStopProfile("grDrawCar*");
|
||||||
|
|
||||||
START_PROFILE("grDrawScene*");
|
GfProfStartProfile("grDrawScene*");
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
if (mirrorFlag == 1)
|
if (mirrorFlag == 1)
|
||||||
|
@ -262,7 +262,7 @@ void cGrScreen::camDraw(tSituation *s)
|
||||||
speedcar = 0.0f;
|
speedcar = 0.0f;
|
||||||
grDrawScene(speedcar, s);
|
grDrawScene(speedcar, s);
|
||||||
//grDrawScene();
|
//grDrawScene();
|
||||||
STOP_PROFILE("grDrawScene*");
|
GfProfStopProfile("grDrawScene*");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,18 +339,18 @@ void cGrScreen::update(tSituation *s, float Fps)
|
||||||
glViewport (scrx, scry, scrw, scrh);
|
glViewport (scrx, scry, scrw, scrh);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_PROFILE("boardCam*");
|
GfProfStartProfile("boardCam*");
|
||||||
boardCam->action();
|
boardCam->action();
|
||||||
STOP_PROFILE("boardCam*");
|
GfProfStopProfile("boardCam*");
|
||||||
|
|
||||||
START_PROFILE("grDisp**");
|
GfProfStartProfile("grDisp**");
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
TRACE_GL("cGrScreen::update glDisable(GL_DEPTH_TEST)");
|
TRACE_GL("cGrScreen::update glDisable(GL_DEPTH_TEST)");
|
||||||
board->refreshBoard(s, Fps, 0, curCar);
|
board->refreshBoard(s, Fps, 0, curCar);
|
||||||
TRACE_GL("cGrScreen::update display boards");
|
TRACE_GL("cGrScreen::update display boards");
|
||||||
|
|
||||||
STOP_PROFILE("grDisp**");
|
GfProfStopProfile("grDisp**");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cGrScreen::loadParams(tSituation *s)
|
void cGrScreen::loadParams(tSituation *s)
|
||||||
|
|
Loading…
Reference in a new issue