summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbentzel <cbentzel@chromium.org>2015-08-21 11:23:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-21 18:23:51 +0000
commite45ccbad4d8a66432488fde4ba555a51cf467051 (patch)
treeeea900f2e81b44d6e2e6512bcfc148f19bc12281
parent73df5c7ea28af683ee3235c6bf34b50e3f9b77d9 (diff)
downloadchromium_src-e45ccbad4d8a66432488fde4ba555a51cf467051.zip
chromium_src-e45ccbad4d8a66432488fde4ba555a51cf467051.tar.gz
chromium_src-e45ccbad4d8a66432488fde4ba555a51cf467051.tar.bz2
Record Net.ProxyScriptFetcher.FirstByteDuration
This measures how long until the first byte is received for a PAC script. It's possible that we want to terminate fetching a PAC script if time-to-first-byte is longer than a specific cutoff point, rather than total time for the entire PAC script. BUG=251682 Review URL: https://codereview.chromium.org/1302613003 Cr-Commit-Position: refs/heads/master@{#344819}
-rw-r--r--net/proxy/proxy_script_fetcher_impl.cc17
-rw-r--r--net/proxy/proxy_script_fetcher_impl.h5
-rw-r--r--tools/metrics/histograms/histograms.xml11
3 files changed, 27 insertions, 6 deletions
diff --git a/net/proxy/proxy_script_fetcher_impl.cc b/net/proxy/proxy_script_fetcher_impl.cc
index 6534150..8f728f7 100644
--- a/net/proxy/proxy_script_fetcher_impl.cc
+++ b/net/proxy/proxy_script_fetcher_impl.cc
@@ -135,7 +135,7 @@ int ProxyScriptFetcherImpl::Fetch(
}
DCHECK(fetch_start_time_.is_null());
- fetch_start_time_ = base::Time::Now();
+ fetch_start_time_ = base::TimeTicks::Now();
cur_request_ =
url_request_context_->CreateRequest(url, DEFAULT_PRIORITY, this);
@@ -280,6 +280,11 @@ bool ProxyScriptFetcherImpl::ConsumeBytesRead(URLRequest* request,
return false;
}
+ if (bytes_read_so_far_.empty()) {
+ DCHECK(fetch_time_to_first_byte_.is_null());
+ fetch_time_to_first_byte_ = base::TimeTicks::Now();
+ }
+
bytes_read_so_far_.append(buf_->data(), num_bytes);
return true;
}
@@ -288,8 +293,11 @@ void ProxyScriptFetcherImpl::FetchCompleted() {
if (result_code_ == OK) {
// Calculate duration of time for proxy script fetch to complete.
DCHECK(!fetch_start_time_.is_null());
- UMA_HISTOGRAM_TIMES("Net.ProxyScriptFetcher.SuccessDuration",
- base::Time::Now() - fetch_start_time_);
+ DCHECK(!fetch_time_to_first_byte_.is_null());
+ UMA_HISTOGRAM_MEDIUM_TIMES("Net.ProxyScriptFetcher.SuccessDuration",
+ base::TimeTicks::Now() - fetch_start_time_);
+ UMA_HISTOGRAM_MEDIUM_TIMES("Net.ProxyScriptFetcher.FirstByteDuration",
+ fetch_time_to_first_byte_ - fetch_start_time_);
// The caller expects the response to be encoded as UTF16.
std::string charset;
@@ -314,7 +322,8 @@ void ProxyScriptFetcherImpl::ResetCurRequestState() {
callback_.Reset();
result_code_ = OK;
result_text_ = NULL;
- fetch_start_time_ = base::Time();
+ fetch_start_time_ = base::TimeTicks();
+ fetch_time_to_first_byte_ = base::TimeTicks();
}
void ProxyScriptFetcherImpl::OnTimeout(int id) {
diff --git a/net/proxy/proxy_script_fetcher_impl.h b/net/proxy/proxy_script_fetcher_impl.h
index 85ad7a0..b02c9fc 100644
--- a/net/proxy/proxy_script_fetcher_impl.h
+++ b/net/proxy/proxy_script_fetcher_impl.h
@@ -117,7 +117,10 @@ class NET_EXPORT ProxyScriptFetcherImpl : public ProxyScriptFetcher,
base::TimeDelta max_duration_;
// The time that the fetch started.
- base::Time fetch_start_time_;
+ base::TimeTicks fetch_start_time_;
+
+ // The time that the first byte was received.
+ base::TimeTicks fetch_time_to_first_byte_;
// Factory for creating the time-out task. This takes care of revoking
// outstanding tasks when |this| is deleted.
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 4aefbff..cb3760f 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -22743,11 +22743,20 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>The length of the URL that was passed into the PAC script.</summary>
</histogram>
+<histogram name="Net.ProxyScriptFetcher.FirstByteDuration" units="milliseconds">
+ <owner>cbentzel@chromium.org</owner>
+ <summary>
+ The time taken from requesting a PAC script to receiving the first byte, on
+ successful fetches. This does not include time spent doing proxy
+ auto-discovery, or failed attempts at retrieving PAC scripts.
+ </summary>
+</histogram>
+
<histogram name="Net.ProxyScriptFetcher.SuccessDuration" units="milliseconds">
<owner>cbentzel@chromium.org</owner>
<summary>
The time taken to successfully fetch a PAC script. This does not include
- time spent doing proxy auto-discovery, or failed attempts at retrieiving PAC
+ time spent doing proxy auto-discovery, or failed attempts at retrieving PAC
scripts.
</summary>
</histogram>