a=don, r=pollmann.

- Don't use nsStackBasedTimer.h any more
- Fix compile errors in __mysprintf() in nsTimer.cpp
- Make stack based timers work.
This commit is contained in:
nisheeth%netscape.com 1999-12-22 23:55:29 +00:00
parent 1e9fb0f783
commit f08ec33266
6 changed files with 31 additions and 10 deletions

View File

@ -5,4 +5,3 @@
xp_obs.h
stopwatch.h
nsTimer.h
nsStackBasedTimer.h

View File

@ -31,8 +31,7 @@ XPIDL_MODULE = util
EXPORTS = $(srcdir)/xp_obs.h \
$(srcdir)/stopwatch.h \
$(srcdir)/nsTimer.h \
$(srcdir)/nsStackBasedTimer.h
$(srcdir)/nsTimer.h
XPIDLSRCS = nsITimeRecorder.idl

View File

@ -33,8 +33,7 @@ XPIDLSRCS = \
EXPORTS=xp_obs.h \
stopwatch.h \
nsTimer.h \
nsStackBasedTimer.h
nsTimer.h
!include $(DEPTH)\config\rules.mak

View File

@ -26,7 +26,23 @@
#ifdef MOZ_PERF_METRICS
#include "stopwatch.h"
#include "nsStackBasedTimer.h"
class nsStackBasedTimer
{
public:
nsStackBasedTimer(Stopwatch* aStopwatch) { sw = aStopwatch; }
~nsStackBasedTimer() { if (sw) sw->Stop(); }
void Start(PRBool aReset) { if (sw) sw->Start(aReset); }
void Stop(void) { if (sw) sw->Stop(); }
void Reset(void) { if (sw) sw->Reset(); }
void SaveState(void) { if (sw) sw->SaveState(); }
void RestoreState(void) { if (sw) sw->RestoreState(); }
void Print(void) { if (sw) sw->Print(); }
private:
Stopwatch* sw;
};
// This should be set from preferences at runtime. For now, make it a compile time flag.
#define ENABLE_DEBUG_OUTPUT PR_FALSE

View File

@ -24,8 +24,14 @@ DEPTH=..\..\..
CSRCS=obs.c
REQUIRES=nspr util
LIBRARY_NAME=util
CPPSRCS=stopwatch.cpp
CPP_OBJS=.\$(OBJDIR)\stopwatch.obj
CPPSRCS=stopwatch.cpp \
nsTimer.cpp \
$(NULL)
CPP_OBJS=.\$(OBJDIR)\stopwatch.obj \
.\$(OBJDIR)\nsTimer.obj \
$(NULL)
C_OBJS=.\$(OBJDIR)\obs.obj

View File

@ -22,12 +22,14 @@
#include "nsTimer.h"
#include <stdarg.h>
#include <stdio.h>
char* __mysprintf(char* aFormatString, ... )
{
va_list argList;
int size = vprintf(aFormatString, argList);
char* buf = new(sizeof(char) * size);
char* buf = new char[size];
vsprintf(buf, aFormatString, argList);
return buf;
}
}