Bug 800031. Include paint time int tab switch telemetry. r=ehsan,dao,bjcaob

This adds a new FX_TAB_SWITCH_TOTAL_MS that should more accurately represent
the user experience of tab switch time than FX_TAB_SWITCH_UPDATE_MS.
FX_TAB_SWITCH_UPDATE_MS is being kept because it gives a good indication of how
much time is being spent in the front end parts vs the painting parts.

This works by measuring the time between beginTabSwitch() and the first call to
LayerManager::PostPresent().
This commit is contained in:
Jeff Muizelaar 2012-10-11 13:54:27 -04:00
parent d00b4328ad
commit 07b8aa36d6
7 changed files with 52 additions and 3 deletions

View File

@ -836,8 +836,11 @@
if (this.mCurrentBrowser == newBrowser && !aForceUpdate)
return;
if (!aForceUpdate)
if (!aForceUpdate) {
TelemetryStopwatch.start("FX_TAB_SWITCH_UPDATE_MS");
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils)
.beginTabSwitch();
}
var oldTab = this.mCurrentTab;

View File

@ -2132,6 +2132,26 @@ nsDOMWindowUtils::StopFrameTimeRecording(uint32_t *frameCount, float **frames)
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::BeginTabSwitch()
{
if (!IsUniversalXPConnectCapable()) {
return NS_ERROR_DOM_SECURITY_ERR;
}
nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget)
return NS_ERROR_FAILURE;
LayerManager *mgr = widget->GetLayerManager();
if (!mgr)
return NS_ERROR_FAILURE;
mgr->BeginTabSwitch();
return NS_OK;
}
static bool
ComputeAnimationValue(nsCSSProperty aProperty,
Element* aElement,

View File

@ -40,7 +40,7 @@ interface nsIDOMTouch;
interface nsIDOMClientRect;
interface nsIURI;
[scriptable, uuid(a76927b7-4aca-4cd1-9c2b-a6b4789b88c3)]
[scriptable, uuid(12167eee-ff9c-4c8e-a89d-b097b1825089)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -1050,6 +1050,12 @@ interface nsIDOMWindowUtils : nsISupports {
void startFrameTimeRecording();
void stopFrameTimeRecording([optional] out unsigned long frameCount,
[retval, array, size_is(frameCount)] out float frameTime);
/**
* Signals that we're begining to tab switch. This is used by painting code to
* determine total tab switch time.
*/
void beginTabSwitch();
/**
* The DPI of the display
*/

View File

@ -7,6 +7,7 @@
#include "mozilla/layers/PLayers.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/Telemetry.h"
#include "ImageLayers.h"
#include "ImageContainer.h"
@ -876,6 +877,11 @@ LayerManager::PostPresent()
mFrameTimes.AppendElement((now - mLastFrameTime).ToMilliseconds());
mLastFrameTime = now;
}
if (!mTabSwitchStart.IsNull()) {
Telemetry::Accumulate(Telemetry::FX_TAB_SWITCH_TOTAL_MS,
uint32_t((TimeStamp::Now() - mTabSwitchStart).ToMilliseconds()));
mTabSwitchStart = TimeStamp();
}
}
nsTArray<float>
@ -887,7 +893,11 @@ LayerManager::StopFrameTimeRecording()
return result;
}
void
LayerManager::BeginTabSwitch()
{
mTabSwitchStart = TimeStamp::Now();
}
#ifdef MOZ_LAYERS_HAVE_LOG

View File

@ -468,6 +468,8 @@ public:
void PostPresent();
void BeginTabSwitch();
static bool IsLogEnabled();
static PRLogModuleInfo* GetLog() { return sLog; }
@ -495,6 +497,7 @@ protected:
private:
TimeStamp mLastFrameTime;
nsTArray<float> mFrameTimes;
TimeStamp mTabSwitchStart;
};
class ThebesLayer;

View File

@ -590,6 +590,7 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
if (mWidget) {
FlashWidgetUpdateArea(mTarget);
}
LayerManager::PostPresent();
}
if (!mTransactionIncomplete) {

View File

@ -1927,6 +1927,12 @@
"n_buckets": 20,
"description": "Firefox: Time in ms spent updating UI in response to a tab switch"
},
"FX_TAB_SWITCH_TOTAL_MS": {
"kind": "exponential",
"high": "1000",
"n_buckets": 20,
"description": "Firefox: Time in ms till a tab switch is complete including the first paint"
},
"FX_KEYWORD_URL_USERSET": {
"kind": "boolean",
"description": "Firefox: keyword.URL has a user-set value"