summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTommy Nyquist <nyquist@chromium.org>2015-06-12 15:54:21 -0700
committerTommy Nyquist <nyquist@chromium.org>2015-06-12 22:55:42 +0000
commitdeff5d42bbf61d477b6ac94608ae6bca99b30bbb (patch)
treed63d413e5e6ec8479fbbd54c6167ae55a2f0739e
parentc0c3bef1456ed718f17f8c820d7711913d9e2bf0 (diff)
downloadchromium_src-deff5d42bbf61d477b6ac94608ae6bca99b30bbb.zip
chromium_src-deff5d42bbf61d477b6ac94608ae6bca99b30bbb.tar.gz
chromium_src-deff5d42bbf61d477b6ac94608ae6bca99b30bbb.tar.bz2
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}
-rw-r--r--components/dom_distiller/content/distiller_page_web_contents.cc14
-rw-r--r--components/dom_distiller/content/distiller_page_web_contents.h1
-rw-r--r--tools/metrics/histograms/histograms.xml9
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<base::Value> 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.
</summary>
</histogram>
+<histogram name="DomDistiller.Time.RunJavaScript" units="milliseconds">
+ <owner>wychen@chromium.org</owner>
+ <summary>
+ Time spent in ExecuteJavaScript() in DomDistiller. It includes JavaScript
+ code transmission through IPC, parsing, compilation, execution, and
+ returning the JSON back through IPC.
+ </summary>
+</histogram>
+
<histogram name="DOMStorage.clear" units="milliseconds">
<obsolete>
Deprecated 2012.