diff --git a/mailnews/local/src/nsParseMailbox.cpp b/mailnews/local/src/nsParseMailbox.cpp index 8962f922f373..180e99f93937 100644 --- a/mailnews/local/src/nsParseMailbox.cpp +++ b/mailnews/local/src/nsParseMailbox.cpp @@ -42,8 +42,12 @@ #include "nsIMsgFilterList.h" #include "nsIMsgFilter.h" +#include "nsIPref.h" + + static NS_DEFINE_CID(kCMailDB, NS_MAILDB_CID); static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID); +static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); // we need this because of an egcs 1.0 (and possibly gcc) compiler bug // that doesn't allow you to call ::nsISupports::GetIID() inside of a class @@ -68,11 +72,18 @@ NS_IMETHODIMP nsMsgMailboxParser::OnDataAvailable(nsIChannel * /* aChannel */, n NS_IMETHODIMP nsMsgMailboxParser::OnStartRequest(nsIChannel * /* aChannel */, nsISupports *ctxt) { + nsTime currentTime; + m_startTime = currentTime; + + // extract the appropriate event sinks from the url and initialize them in our protocol data // the URL should be queried for a nsIMailboxURL. If it doesn't support a mailbox URL interface then // we have an error. nsresult rv = NS_OK; + + nsCOMPtr runningUrl = do_QueryInterface(ctxt, &rv); + nsCOMPtr url = do_QueryInterface(ctxt); if (NS_SUCCEEDED(rv) && runningUrl) @@ -157,10 +168,31 @@ NS_IMETHODIMP nsMsgMailboxParser::OnStopRequest(nsIChannel * /* aChannel */, nsI } #endif + // be sure to clear any status text and progress info.. m_graph_progress_received = 0; UpdateProgressPercent(); UpdateStatusText(LOCAL_STATUS_DOCUMENT_DONE); + + + //For timing + nsresult rv; + NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); + if(NS_SUCCEEDED(rv)) + { + PRBool showPerf; + rv = prefs->GetBoolPref("mail.showMessengerPerformance", &showPerf); + if(NS_SUCCEEDED(rv) && showPerf) + { + nsTime currentTime; + nsInt64 difference = currentTime - m_startTime; + nsInt64 seconds(1000000); + nsInt64 timeInSeconds = difference / seconds; + PRUint32 timeInSecondsUint32 = (PRUint32)timeInSeconds; + + printf("Time to parse %s= %d seconds\n", m_mailboxName, timeInSecondsUint32); + } + } return NS_OK; } diff --git a/mailnews/local/src/nsParseMailbox.h b/mailnews/local/src/nsParseMailbox.h index 5146d1cacfd2..e6d97d760386 100644 --- a/mailnews/local/src/nsParseMailbox.h +++ b/mailnews/local/src/nsParseMailbox.h @@ -31,6 +31,7 @@ #include "nsIMsgStatusFeedback.h" #include "nsXPIDLString.h" #include "nsCOMPtr.h" +#include "nsTime.h" #include "nsIMsgFilterList.h" @@ -203,6 +204,7 @@ protected: PRBool m_parsingDone; PRBool m_ignoreNonMailFolder; PRBool m_isRealMailFolder; + nsTime m_startTime; private: // the following flag is used to determine when a url is currently being run. It is cleared on calls // to ::StopBinding and it is set whenever we call Load on a url