mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 1115130 - Add logging for User Timing API; r=baku
This commit is contained in:
parent
90280e7c4b
commit
886508ba5d
@ -242,6 +242,7 @@ bool nsContentUtils::sTrustedFullScreenOnly = true;
|
||||
bool nsContentUtils::sFullscreenApiIsContentOnly = false;
|
||||
bool nsContentUtils::sIsPerformanceTimingEnabled = false;
|
||||
bool nsContentUtils::sIsResourceTimingEnabled = false;
|
||||
bool nsContentUtils::sIsUserTimingLoggingEnabled = false;
|
||||
bool nsContentUtils::sIsExperimentalAutocompleteEnabled = false;
|
||||
bool nsContentUtils::sEncodeDecodeURLHash = false;
|
||||
|
||||
@ -515,6 +516,9 @@ nsContentUtils::Init()
|
||||
Preferences::AddBoolVarCache(&sIsResourceTimingEnabled,
|
||||
"dom.enable_resource_timing", true);
|
||||
|
||||
Preferences::AddBoolVarCache(&sIsUserTimingLoggingEnabled,
|
||||
"dom.performance.enable_user_timing_logging", false);
|
||||
|
||||
Preferences::AddBoolVarCache(&sIsExperimentalAutocompleteEnabled,
|
||||
"dom.forms.autocomplete.experimental", false);
|
||||
|
||||
|
@ -1880,6 +1880,14 @@ public:
|
||||
return sIsPerformanceTimingEnabled;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if user timing API should print to console.
|
||||
*/
|
||||
static bool IsUserTimingLoggingEnabled()
|
||||
{
|
||||
return sIsUserTimingLoggingEnabled;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the performance timing APIs are enabled.
|
||||
*/
|
||||
@ -2360,6 +2368,7 @@ private:
|
||||
static uint32_t sHandlingInputTimeout;
|
||||
static bool sIsPerformanceTimingEnabled;
|
||||
static bool sIsResourceTimingEnabled;
|
||||
static bool sIsUserTimingLoggingEnabled;
|
||||
static bool sIsExperimentalAutocompleteEnabled;
|
||||
static bool sEncodeDecodeURLHash;
|
||||
|
||||
|
@ -22,8 +22,15 @@
|
||||
#include "mozilla/dom/PerformanceBinding.h"
|
||||
#include "mozilla/dom/PerformanceTimingBinding.h"
|
||||
#include "mozilla/dom/PerformanceNavigationBinding.h"
|
||||
#include "mozilla/IntegerPrintfMacros.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#define PERFLOG(msg, ...) __android_log_print(ANDROID_LOG_INFO, "PerformanceTiming", msg, ##__VA_ARGS__)
|
||||
#else
|
||||
#define PERFLOG(msg, ...) printf_stderr(msg, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -589,7 +596,7 @@ nsPerformance::AddEntry(nsIHttpChannel* channel,
|
||||
initiatorType = NS_LITERAL_STRING("other");
|
||||
}
|
||||
performanceEntry->SetInitiatorType(initiatorType);
|
||||
InsertPerformanceEntry(performanceEntry);
|
||||
InsertPerformanceEntry(performanceEntry, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -614,7 +621,8 @@ nsPerformance::PerformanceEntryComparator::LessThan(
|
||||
}
|
||||
|
||||
void
|
||||
nsPerformance::InsertPerformanceEntry(PerformanceEntry* aEntry)
|
||||
nsPerformance::InsertPerformanceEntry(PerformanceEntry* aEntry,
|
||||
bool aShouldPrint)
|
||||
{
|
||||
MOZ_ASSERT(aEntry);
|
||||
MOZ_ASSERT(mEntries.Length() < mPrimaryBufferSize);
|
||||
@ -622,6 +630,21 @@ nsPerformance::InsertPerformanceEntry(PerformanceEntry* aEntry)
|
||||
NS_WARNING("Performance Entry buffer size maximum reached!");
|
||||
return;
|
||||
}
|
||||
if (aShouldPrint && nsContentUtils::IsUserTimingLoggingEnabled()) {
|
||||
nsAutoCString uri;
|
||||
nsresult rv = mWindow->GetDocumentURI()->GetHost(uri);
|
||||
if(NS_FAILED(rv)) {
|
||||
// If we have no URI, just put in "none".
|
||||
uri.AssignLiteral("none");
|
||||
}
|
||||
PERFLOG("Performance Entry: %s|%s|%s|%f|%f|%" PRIu64 "\n",
|
||||
uri.get(),
|
||||
NS_ConvertUTF16toUTF8(aEntry->GetEntryType()).get(),
|
||||
NS_ConvertUTF16toUTF8(aEntry->GetName()).get(),
|
||||
aEntry->StartTime(),
|
||||
aEntry->Duration(),
|
||||
static_cast<uint64_t>(PR_Now() / PR_USEC_PER_MSEC));
|
||||
}
|
||||
mEntries.InsertElementSorted(aEntry,
|
||||
PerformanceEntryComparator());
|
||||
if (mEntries.Length() == mPrimaryBufferSize) {
|
||||
@ -645,7 +668,7 @@ nsPerformance::Mark(const nsAString& aName, ErrorResult& aRv)
|
||||
}
|
||||
nsRefPtr<PerformanceMark> performanceMark =
|
||||
new PerformanceMark(this, aName);
|
||||
InsertPerformanceEntry(performanceMark);
|
||||
InsertPerformanceEntry(performanceMark, true);
|
||||
}
|
||||
|
||||
void
|
||||
@ -722,7 +745,7 @@ nsPerformance::Measure(const nsAString& aName,
|
||||
}
|
||||
nsRefPtr<PerformanceMeasure> performanceMeasure =
|
||||
new PerformanceMeasure(this, aName, startTime, endTime);
|
||||
InsertPerformanceEntry(performanceMeasure);
|
||||
InsertPerformanceEntry(performanceMeasure, true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -353,7 +353,7 @@ private:
|
||||
DOMTimeMilliSec GetPerformanceTimingFromString(const nsAString& aTimingName);
|
||||
DOMHighResTimeStamp ConvertDOMMilliSecToHighRes(const DOMTimeMilliSec aTime);
|
||||
void DispatchBufferFullEvent();
|
||||
void InsertPerformanceEntry(PerformanceEntry* aEntry);
|
||||
void InsertPerformanceEntry(PerformanceEntry* aEntry, bool aShouldPrint);
|
||||
void ClearEntries(const mozilla::dom::Optional<nsAString>& aEntryName,
|
||||
const nsAString& aEntryType);
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
|
@ -147,6 +147,9 @@ pref("dom.enable_resource_timing", true);
|
||||
// Enable high-resolution timing markers for users
|
||||
pref("dom.enable_user_timing", true);
|
||||
|
||||
// Enable printing performance marks/measures to log
|
||||
pref("dom.performance.enable_user_timing_logging", false);
|
||||
|
||||
// Whether the Gamepad API is enabled
|
||||
pref("dom.gamepad.enabled", true);
|
||||
#ifdef RELEASE_BUILD
|
||||
|
Loading…
Reference in New Issue
Block a user