From 502d3702ecc2e1ccc39cf6275bf49c12902cc11b Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Fri, 23 Apr 1999 19:48:05 +0000 Subject: [PATCH] Added code to measure document load times --- webshell/tests/viewer/nsBrowserWindow.cpp | 12 ++++++++++++ webshell/tests/viewer/nsBrowserWindow.h | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/webshell/tests/viewer/nsBrowserWindow.cpp b/webshell/tests/viewer/nsBrowserWindow.cpp index e96dcc6874e..ac617b0aaee 100644 --- a/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/webshell/tests/viewer/nsBrowserWindow.cpp @@ -1651,6 +1651,7 @@ nsBrowserWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadT PRUint32 size; mStatus->SetText(url,size); } + mLoadStartTime = PR_Now(); return NS_OK; } @@ -1679,6 +1680,17 @@ nsBrowserWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus) { + PRTime endLoadTime = PR_Now(); + if (mShowLoadTimes) { + nsAutoString msg(aURL); + printf("Loading "); + fputs(msg, stdout); + PRTime delta; + LL_SUB(delta, endLoadTime, mLoadStartTime); + double usecs; + LL_L2D(usecs, delta); + printf(" took %g milliseconds\n", usecs / 1000.0); + } if (mThrobber) { mThrobber->Stop(); } diff --git a/webshell/tests/viewer/nsBrowserWindow.h b/webshell/tests/viewer/nsBrowserWindow.h index edc606b332c..266e4dc5251 100644 --- a/webshell/tests/viewer/nsBrowserWindow.h +++ b/webshell/tests/viewer/nsBrowserWindow.h @@ -27,7 +27,7 @@ #include "nsString.h" #include "nsVoidArray.h" #include "nsCRT.h" -//#include "nsIPref.h" +#include "prtime.h" #include "nsIXPBaseWindow.h" #include "nsPrintSetupDialog.h" @@ -202,6 +202,10 @@ public: static void CloseAllWindows(); + void SetShowLoadTimes(PRBool aOn) { + mShowLoadTimes = aOn; + } + nsViewerApp* mApp; PRUint32 mChromeMask; @@ -212,6 +216,9 @@ public: nsString mOpenFileDirectory; + PRTime mLoadStartTime; + PRBool mShowLoadTimes; + // "Toolbar" nsITextWidget* mLocation; nsIButton* mBack;