From deff5d42bbf61d477b6ac94608ae6bca99b30bbb Mon Sep 17 00:00:00 2001 From: Tommy Nyquist Date: Fri, 12 Jun 2015 15:54:21 -0700 Subject: Add UMA histogram DomDistiller.Time.RunJavaScript This measures time spent in ExecuteJavaScript() in DomDistiller. It includes JavaScript code transmission through IPC, parsing, compilation, execution, and returning the JSON back through IPC. We already have DomDistiller.Time.DistillationTotal, but it is measured within JavaScript. In DomDistiller.Time.*, DistillationTotal < RunJavaScript < DistillPage. BUG=497430 Review URL: https://codereview.chromium.org/1143173009 Cr-Commit-Position: refs/heads/master@{#333670} (cherry picked from commit 96a824763c2cbb50b4b0bbad2b7531c3fdd5ce6e) Review URL: https://codereview.chromium.org/1178863003. Cr-Commit-Position: refs/branch-heads/2403@{#296} Cr-Branched-From: f54b8097a9c45ed4ad308133d49f05325d6c5070-refs/heads/master@{#330231} --- .../dom_distiller/content/distiller_page_web_contents.cc | 14 ++++++++++++-- .../dom_distiller/content/distiller_page_web_contents.h | 1 + tools/metrics/histograms/histograms.xml | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/components/dom_distiller/content/distiller_page_web_contents.cc b/components/dom_distiller/content/distiller_page_web_contents.cc index feaa259..d8d7f60 100644 --- a/components/dom_distiller/content/distiller_page_web_contents.cc +++ b/components/dom_distiller/content/distiller_page_web_contents.cc @@ -6,6 +6,7 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" +#include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" #include "components/dom_distiller/content/web_contents_main_frame_observer.h" #include "components/dom_distiller/core/distiller_page.h" @@ -164,7 +165,7 @@ void DistillerPageWebContents::DidFailLoad( DCHECK(state_ == LOADING_PAGE || state_ == EXECUTING_JAVASCRIPT); state_ = PAGELOAD_FAILED; scoped_ptr empty = base::Value::CreateNullValue(); - OnWebContentsDistillationDone(GURL(), empty.get()); + OnWebContentsDistillationDone(GURL(), base::TimeTicks(), empty.get()); } } @@ -183,14 +184,23 @@ void DistillerPageWebContents::ExecuteJavaScript() { base::UTF8ToUTF16(script_), base::Bind(&DistillerPageWebContents::OnWebContentsDistillationDone, base::Unretained(this), - source_page_handle_->web_contents()->GetLastCommittedURL())); + source_page_handle_->web_contents()->GetLastCommittedURL(), + base::TimeTicks::Now())); } void DistillerPageWebContents::OnWebContentsDistillationDone( const GURL& page_url, + const base::TimeTicks& javascript_start, const base::Value* value) { DCHECK(state_ == PAGELOAD_FAILED || state_ == EXECUTING_JAVASCRIPT); state_ = IDLE; + + if (!javascript_start.is_null()) { + base::TimeDelta javascript_time = base::TimeTicks::Now() - javascript_start; + UMA_HISTOGRAM_TIMES("DomDistiller.Time.RunJavaScript", javascript_time); + DVLOG(1) << "DomDistiller.Time.RunJavaScript = " << javascript_time; + } + DistillerPage::OnDistillationDone(page_url, value); } diff --git a/components/dom_distiller/content/distiller_page_web_contents.h b/components/dom_distiller/content/distiller_page_web_contents.h index 82abe8d..f276080 100644 --- a/components/dom_distiller/content/distiller_page_web_contents.h +++ b/components/dom_distiller/content/distiller_page_web_contents.h @@ -100,6 +100,7 @@ class DistillerPageWebContents : public DistillerPage, // Called when the distillation is done or if the page load failed. void OnWebContentsDistillationDone(const GURL& page_url, + const base::TimeTicks& javascript_start, const base::Value* value); // The current state of the |DistillerPage|, initially |IDLE|. diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 50e0694..73d03fe 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -6233,6 +6233,15 @@ Therefore, the affected-histogram name has to have at least one dot in it. + + wychen@chromium.org + + Time spent in ExecuteJavaScript() in DomDistiller. It includes JavaScript + code transmission through IPC, parsing, compilation, execution, and + returning the JSON back through IPC. + + + Deprecated 2012. -- cgit v1.1