Commit 0c6966df authored by Devdeep Ray's avatar Devdeep Ray Committed by Commit Bot

Add UMA to record priority keyed completion times of requests

Bug: 741924
Change-Id: Ifd3355657a30a0e40d73517fbf79dca41d992512
Reviewed-on: https://chromium-review.googlesource.com/568716
Commit-Queue: Devdeep Ray <devdeepray@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486563}
parent 442c8bcf
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
#include "base/location.h" #include "base/location.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/profiler/scoped_tracker.h" #include "base/profiler/scoped_tracker.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
...@@ -1509,6 +1511,10 @@ void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) { ...@@ -1509,6 +1511,10 @@ void URLRequestHttpJob::RecordPerfHistograms(CompletionCause reason) {
UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTime", total_time); UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTime", total_time);
if (reason == FINISHED) { if (reason == FINISHED) {
UmaHistogramTimes(
base::StringPrintf("Net.HttpJob.TotalTimeSuccess.Priority%d",
request()->priority()),
total_time);
UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeSuccess", total_time); UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeSuccess", total_time);
} else { } else {
UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeCancel", total_time); UMA_HISTOGRAM_TIMES("Net.HttpJob.TotalTimeCancel", total_time);
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/test/histogram_tester.h" #include "base/test/histogram_tester.h"
#include "net/base/auth.h" #include "net/base/auth.h"
...@@ -813,6 +814,40 @@ TEST_F(URLRequestHttpJobWithMockSocketsTest, ...@@ -813,6 +814,40 @@ TEST_F(URLRequestHttpJobWithMockSocketsTest,
histograms.ExpectTotalCount("Net.HttpTimeToFirstByte", 0); histograms.ExpectTotalCount("Net.HttpTimeToFirstByte", 0);
} }
TEST_F(URLRequestHttpJobWithMockSocketsTest,
TestHttpJobSuccessPriorityKeyedTotalTime) {
base::HistogramTester histograms;
for (int priority = 0; priority < net::NUM_PRIORITIES; ++priority) {
for (int request_index = 0; request_index <= priority; ++request_index) {
MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)};
MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n"
"Content-Length: 12\r\n\r\n"),
MockRead("Test Content")};
StaticSocketDataProvider socket_data(reads, arraysize(reads), writes,
arraysize(writes));
socket_factory_.AddSocketDataProvider(&socket_data);
TestDelegate delegate;
std::unique_ptr<URLRequest> request =
context_->CreateRequest(GURL("http://www.example.com/"),
static_cast<net::RequestPriority>(priority),
&delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
request->Start();
base::RunLoop().Run();
EXPECT_THAT(delegate.request_status(), IsOk());
}
}
for (int priority = 0; priority < net::NUM_PRIORITIES; ++priority) {
histograms.ExpectTotalCount(
"Net.HttpJob.TotalTimeSuccess.Priority" + base::IntToString(priority),
priority + 1);
}
}
TEST_F(URLRequestHttpJobTest, TestCancelWhileReadingCookies) { TEST_F(URLRequestHttpJobTest, TestCancelWhileReadingCookies) {
DelayedCookieMonster cookie_monster; DelayedCookieMonster cookie_monster;
TestURLRequestContext context(true); TestURLRequestContext context(true);
......
...@@ -92489,6 +92489,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -92489,6 +92489,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<affected-histogram name="Net.BidirectionalStream.TimeToSendStart"/> <affected-histogram name="Net.BidirectionalStream.TimeToSendStart"/>
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="Net.HttpJob.TotalTimeSuccess.Priorities"
separator=".">
<suffix name="Priority0" label="THROTTLED or MINIMUM_PRIORITY"/>
<suffix name="Priority1" label="IDLE"/>
<suffix name="Priority2" label="LOWEST or DEFAULT_PRIORITY"/>
<suffix name="Priority3" label="LOW"/>
<suffix name="Priority4" label="MEDIUM"/>
<suffix name="Priority5" label="HIGHEST or MAXIMUM_PRIORITY"/>
<affected-histogram name="Net.HttpJob.TotalTimeSuccess"/>
</histogram_suffixes>
<histogram_suffixes name="Net.QuicClientHelloRejectReasons.QuicIsSecureOrNot" <histogram_suffixes name="Net.QuicClientHelloRejectReasons.QuicIsSecureOrNot"
separator="."> separator=".">
<owner>rch@chromium.org</owner> <owner>rch@chromium.org</owner>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment