summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-16 22:34:12 +0000
committertburkard@chromium.org <tburkard@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-16 22:34:12 +0000
commitb86aad87785f4cdeaf9839619b2d1cc7e32e2f7f (patch)
tree4ccb64e645c48a9819849be5296eb4ff976b3d65
parent29da574bcb6d6c958685b508efda39621af3a973 (diff)
downloadchromium_src-b86aad87785f4cdeaf9839619b2d1cc7e32e2f7f.zip
chromium_src-b86aad87785f4cdeaf9839619b2d1cc7e32e2f7f.tar.gz
chromium_src-b86aad87785f4cdeaf9839619b2d1cc7e32e2f7f.tar.bz2
Add prerender histograms to record:
- PLT of pages fully loaded before they are swapped in - % of total PLT elapsed at the time the swap-in happens R=cbentzel Review URL: https://chromiumcodereview.appspot.com/9719001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127272 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/prerender/prerender_histograms.cc20
-rw-r--r--chrome/browser/prerender/prerender_histograms.h10
-rw-r--r--chrome/browser/prerender/prerender_manager.cc12
-rw-r--r--chrome/browser/prerender/prerender_manager.h3
-rw-r--r--chrome/browser/prerender/prerender_tab_helper.cc33
-rw-r--r--chrome/browser/prerender/prerender_tab_helper.h5
6 files changed, 73 insertions, 10 deletions
diff --git a/chrome/browser/prerender/prerender_histograms.cc b/chrome/browser/prerender/prerender_histograms.cc
index 451f77b..f9e918a 100644
--- a/chrome/browser/prerender/prerender_histograms.cc
+++ b/chrome/browser/prerender/prerender_histograms.cc
@@ -258,6 +258,26 @@ void PrerenderHistograms::RecordPerceivedPageLoadTime(
}
}
+void PrerenderHistograms::RecordPageLoadTimeNotSwappedIn(
+ base::TimeDelta page_load_time, const GURL& url) const {
+ // If the URL to be prerendered is not a http[s] URL, or is a Google URL,
+ // do not record.
+ if (!IsWebURL(url) || IsGoogleDomain(url))
+ return;
+ RECORD_PLT("PrerenderNotSwappedInPLT", page_load_time);
+}
+
+void PrerenderHistograms::RecordPercentLoadDoneAtSwapin(double fraction)
+ const {
+ if (fraction < 0.0 || fraction > 1.0)
+ return;
+ int percentage = static_cast<int>(fraction * 100);
+ if (percentage < 0 || percentage > 100)
+ return;
+ PREFIXED_HISTOGRAM("PercentLoadDoneAtSwapin",
+ HISTOGRAM_PERCENTAGE(name, percentage));
+}
+
base::TimeDelta PrerenderHistograms::GetTimeSinceLastPrerender() const {
return base::TimeTicks::Now() - last_prerender_seen_time_;
}
diff --git a/chrome/browser/prerender/prerender_histograms.h b/chrome/browser/prerender/prerender_histograms.h
index 75fb00b..abd36ba 100644
--- a/chrome/browser/prerender/prerender_histograms.h
+++ b/chrome/browser/prerender/prerender_histograms.h
@@ -36,6 +36,16 @@ class PrerenderHistograms {
bool was_complete_prerender,
const GURL& url);
+ // Records, in a histogram, the percentage of the page load time that had
+ // elapsed by the time it is swapped in. Values outside of [0, 1.0] are
+ // invalid and ignored.
+ void RecordPercentLoadDoneAtSwapin(double fraction) const;
+
+ // Records the actual pageload time of a prerender that has not been swapped
+ // in yet, but finished loading.
+ void RecordPageLoadTimeNotSwappedIn(base::TimeDelta page_load_time,
+ const GURL& url) const;
+
// Records the time from when a page starts prerendering to when the user
// navigates to it. This must be called on the UI thread.
void RecordTimeUntilUsed(base::TimeDelta time_until_used,
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index 3387ddf..57e77c8 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -542,6 +542,7 @@ void PrerenderManager::MoveEntryToPendingDelete(PrerenderContents* entry,
// static
void PrerenderManager::RecordPerceivedPageLoadTime(
base::TimeDelta perceived_page_load_time,
+ double fraction_plt_elapsed_at_swap_in,
WebContents* web_contents,
const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -556,8 +557,15 @@ void PrerenderManager::RecordPerceivedPageLoadTime(
prerender_manager->IsWebContentsPrerendered(web_contents);
bool was_complete_prerender = was_prerender ||
prerender_manager->WouldWebContentsBePrerendered(web_contents);
- prerender_manager->histograms_->RecordPerceivedPageLoadTime(
- perceived_page_load_time, was_prerender, was_complete_prerender, url);
+ if (prerender_manager->IsWebContentsPrerendering(web_contents)) {
+ prerender_manager->histograms_->RecordPageLoadTimeNotSwappedIn(
+ perceived_page_load_time, url);
+ } else {
+ prerender_manager->histograms_->RecordPerceivedPageLoadTime(
+ perceived_page_load_time, was_prerender, was_complete_prerender, url);
+ prerender_manager->histograms_->RecordPercentLoadDoneAtSwapin(
+ fraction_plt_elapsed_at_swap_in);
+ }
}
bool PrerenderManager::is_enabled() const {
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index a44e7b9..fa0d320 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -140,8 +140,11 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// when the user navigates to a page to when it finishes loading. The actual
// load may have started prior to navigation due to prerender hints.
// This must be called on the UI thread.
+ // |fraction_plt_elapsed_at_swap_in| must either be in [0.0, 1.0], or a value
+ // outside that range indicating that it doesn't apply.
static void RecordPerceivedPageLoadTime(
base::TimeDelta perceived_page_load_time,
+ double fraction_plt_elapsed_at_swap_in,
content::WebContents* web_contents,
const GURL& url);
diff --git a/chrome/browser/prerender/prerender_tab_helper.cc b/chrome/browser/prerender/prerender_tab_helper.cc
index 9c614ce..3885597 100644
--- a/chrome/browser/prerender/prerender_tab_helper.cc
+++ b/chrome/browser/prerender/prerender_tab_helper.cc
@@ -168,7 +168,6 @@ class PrerenderTabHelper::HoverData {
PrerenderTabHelper::PrerenderTabHelper(TabContentsWrapper* tab)
: content::WebContentsObserver(tab->web_contents()),
tab_(tab),
- pplt_load_start_(),
last_hovers_(new HoverData[kNumHoverThresholds]) {
for (int i = 0; i < kNumHoverThresholds; i++)
last_hovers_[i].SetHoverThreshold(kMinHoverThresholdsMs[i]);
@@ -204,17 +203,32 @@ void PrerenderTabHelper::UpdateTargetURL(int32 page_id, const GURL& url) {
}
void PrerenderTabHelper::DidStopLoading() {
- // Don't include prerendered pages in the PPLT metric until after they are
- // swapped in.
-
// Compute the PPLT metric and report it in a histogram, if needed.
- if (!pplt_load_start_.is_null() && !IsPrerendering()) {
+ // We include pages that are still prerendering and have just finished
+ // loading -- PrerenderManager will sort this out and handle it correctly
+ // (putting those times into a separate histogram).
+ if (!pplt_load_start_.is_null()) {
+ double fraction_elapsed_at_swapin = -1.0;
+ base::TimeTicks now = base::TimeTicks::Now();
+ if (!actual_load_start_.is_null()) {
+ double plt = (now - actual_load_start_).InMillisecondsF();
+ if (plt > 0.0) {
+ fraction_elapsed_at_swapin = 1.0 -
+ (now - pplt_load_start_).InMillisecondsF() / plt;
+ } else {
+ fraction_elapsed_at_swapin = 1.0;
+ }
+ DCHECK_GE(fraction_elapsed_at_swapin, 0.0);
+ DCHECK_LE(fraction_elapsed_at_swapin, 1.0);
+ }
PrerenderManager::RecordPerceivedPageLoadTime(
- base::TimeTicks::Now() - pplt_load_start_, web_contents(), url_);
+ now - pplt_load_start_, fraction_elapsed_at_swapin, web_contents(),
+ url_);
}
// Reset the PPLT metric.
pplt_load_start_ = base::TimeTicks();
+ actual_load_start_ = base::TimeTicks();
}
void PrerenderTabHelper::DidStartProvisionalLoadForFrame(
@@ -230,6 +244,7 @@ void PrerenderTabHelper::DidStartProvisionalLoadForFrame(
// Record the beginning of a new PPLT navigation.
pplt_load_start_ = base::TimeTicks::Now();
+ actual_load_start_ = base::TimeTicks();
// Update hover stats.
for (int i = 0; i < kNumHoverThresholds; i++)
@@ -256,10 +271,12 @@ void PrerenderTabHelper::PrerenderSwappedIn() {
DCHECK(!IsPrerendering());
if (pplt_load_start_.is_null()) {
// If we have already finished loading, report a 0 PPLT.
- PrerenderManager::RecordPerceivedPageLoadTime(base::TimeDelta(),
+ PrerenderManager::RecordPerceivedPageLoadTime(base::TimeDelta(), 1.0,
web_contents(), url_);
} else {
- // If we have not finished loading yet, rebase the start time to now.
+ // If we have not finished loading yet, record the actual load start, and
+ // rebase the start time to now.
+ actual_load_start_ = pplt_load_start_;
pplt_load_start_ = base::TimeTicks::Now();
}
}
diff --git a/chrome/browser/prerender/prerender_tab_helper.h b/chrome/browser/prerender/prerender_tab_helper.h
index 1b3ebe2..1631830 100644
--- a/chrome/browser/prerender/prerender_tab_helper.h
+++ b/chrome/browser/prerender/prerender_tab_helper.h
@@ -64,6 +64,11 @@ class PrerenderTabHelper : public content::WebContentsObserver {
// the perceived page load time (PPLT).
base::TimeTicks pplt_load_start_;
+ // System time at which the actual pageload started (pre-swapin), if
+ // a applicable (in cases when a prerender that was still loading was
+ // swapped in).
+ base::TimeTicks actual_load_start_;
+
// Information about the last hover for each hover threshold.
scoped_array<HoverData> last_hovers_;