From bf42b552d510bfd33008fddc846affd15eb2a9b0 Mon Sep 17 00:00:00 2001 From: "nisheeth%netscape.com" Date: Fri, 24 Sep 1999 08:39:43 +0000 Subject: [PATCH] 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 --- mozilla/modules/libutil/public/stopwatch.h | 16 ++++++++++++++++ mozilla/modules/libutil/src/makefile.win | 13 +++++++++---- mozilla/modules/libutil/src/stopwatch.cpp | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/mozilla/modules/libutil/public/stopwatch.h b/mozilla/modules/libutil/public/stopwatch.h index e71dcc9ee59..fe68c8286c3 100644 --- a/mozilla/modules/libutil/public/stopwatch.h +++ b/mozilla/modules/libutil/public/stopwatch.h @@ -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: diff --git a/mozilla/modules/libutil/src/makefile.win b/mozilla/modules/libutil/src/makefile.win index e10d5ef4894..97201c8f818 100644 --- a/mozilla/modules/libutil/src/makefile.win +++ b/mozilla/modules/libutil/src/makefile.win @@ -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 diff --git a/mozilla/modules/libutil/src/stopwatch.cpp b/mozilla/modules/libutil/src/stopwatch.cpp index d8ea890d95f..a0c05868a79 100644 --- a/mozilla/modules/libutil/src/stopwatch.cpp +++ b/mozilla/modules/libutil/src/stopwatch.cpp @@ -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())); }