a=chofmann. Add NSPR logging facilities to the stopwatch code. Make Print() dump stopwatch info to the NSPR log. Set NSPR_LOG_MODULES=gecko_timing:1 in your environment to get timing logs printed to the file specified in the NSPR_LOG_FILE environment variable.
git-svn-id: svn://10.0.0.236/trunk@48974 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "nscore.h"
|
||||
#include "prlog.h"
|
||||
|
||||
const double gTicks = 1.0e-7;
|
||||
|
||||
@@ -26,6 +27,21 @@ const double gTicks = 1.0e-7;
|
||||
# define NS_RESTORE_STOPWATCH_STATE(_sw)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RAPTOR_PERF_METRICS
|
||||
static PRLogModuleInfo* gLogStopwatchModule = PR_NewLogModule("gecko_timing");
|
||||
|
||||
#define RAPTOR_TRACE_STOPWATCHES 0x1
|
||||
|
||||
#define RAPTOR_STOPWATCH_TRACE(_args) \
|
||||
PR_BEGIN_MACRO \
|
||||
PR_LOG(gLogStopwatchModule, RAPTOR_TRACE_STOPWATCHES, _args); \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
#define RAPTOR_TRACE_STOPWATCHES
|
||||
#define RAPTOR_STOPWATCH_TRACE(_args)
|
||||
#endif
|
||||
|
||||
class Stopwatch {
|
||||
|
||||
private:
|
||||
|
||||
@@ -18,12 +18,17 @@
|
||||
MODULE=util
|
||||
DEPTH=..\..\..
|
||||
CSRCS=obs.c
|
||||
!if defined(MOZ_PERF)
|
||||
CPPSRCS=stopwatch.cpp
|
||||
CPP_OBJS=.\$(OBJDIR)\stopwatch.obj
|
||||
!endif
|
||||
REQUIRES=nspr util
|
||||
LIBRARY_NAME=util
|
||||
!if defined(MOZ_PERF)
|
||||
DEFINES=-DRAPTOR_PERF_METRICS
|
||||
CPPSRCS=stopwatch.cpp
|
||||
CPP_OBJS=.\$(OBJDIR)\stopwatch.obj
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
!endif
|
||||
C_OBJS=.\$(OBJDIR)\obs.obj
|
||||
|
||||
|
||||
|
||||
@@ -187,6 +187,6 @@ void Stopwatch::Print(void) {
|
||||
int min = int(realt / 60);
|
||||
realt -= min * 60;
|
||||
int sec = int(realt);
|
||||
printf("Real time %d:%d:%d, CP time %.3f", hours, min, sec, CpuTime());
|
||||
RAPTOR_STOPWATCH_TRACE(("Real time %d:%d:%d, CP time %.3f", hours, min, sec, CpuTime()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user