Bug 628363: make startup measurements less bogus after restart. r=mossop a=mossop

This commit is contained in:
Taras Glek 2011-01-24 22:40:32 -08:00
parent 4c83127f20
commit ba7b7b582d

View File

@ -75,6 +75,7 @@
#include "nsIXPConnect.h"
#include "jsapi.h"
#include "jsdate.h"
#include "prenv.h"
#if defined(XP_WIN)
#include <windows.h>
@ -291,6 +292,11 @@ nsAppStartup::Quit(PRUint32 aMode)
if (!mRestart)
mRestart = (aMode & eRestart) != 0;
if (mRestart) {
// Firefox-restarts reuse the process. Process start-time isn't a useful indicator of startup time
PR_SetEnv(PR_smprintf("MOZ_APP_RESTART=%lld", (PRInt64) PR_Now()));
}
obsService = mozilla::services::GetObserverService();
if (!mAttemptingQuit) {
@ -683,8 +689,12 @@ nsAppStartup::GetStartupInfo()
*retvalPtr = OBJECT_TO_JSVAL(obj);
ncc->SetReturnValueWasSet(PR_TRUE);
if (!gProcessCreationTimestamp)
char *moz_app_restart = PR_GetEnv("MOZ_APP_RESTART");
if (moz_app_restart) {
gProcessCreationTimestamp = nsCRT::atoll(moz_app_restart);
} else if (!gProcessCreationTimestamp) {
gProcessCreationTimestamp = CalculateProcessCreationTimestamp();
}
MaybeDefineProperty(cx, obj, "process", gProcessCreationTimestamp);
#ifdef MOZ_ENABLE_LIBXUL