Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chrome/browser/prerender/prerender_histograms.cc

Issue 2321083002: [NoStatePrefetch] Add performance histograms. (Closed)
Patch Set: Implement discussion conclusions Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prerender/prerender_histograms.h" 5 #include "chrome/browser/prerender/prerender_histograms.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/prerender/prerender_manager.h" 14 #include "chrome/browser/prerender/prerender_manager.h"
15 #include "chrome/browser/prerender/prerender_util.h" 15 #include "chrome/browser/prerender/prerender_util.h"
16 #include "net/http/http_cache.h"
16 17
17 namespace prerender { 18 namespace prerender {
18 19
19 namespace { 20 namespace {
20 21
21 // This enum is used to define the buckets for the 22 // This enum is used to define the buckets for the
22 // "Prerender.NoStatePrefetchResourceCount" histogram family. 23 // "Prerender.NoStatePrefetchResourceCount" histogram family.
23 // Hence, existing enumerated constants should never be deleted or reordered, 24 // Hence, existing enumerated constants should never be deleted or reordered,
24 // and new constants should only be appended at the end of the enumeration. 25 // and new constants should only be appended at the end of the enumeration.
25 enum NoStatePrefetchResponseType { 26 enum NoStatePrefetchResponseType {
(...skipping 14 matching lines...) Expand all
40 void RecordHistogramEnum(std::string histogram_name, 41 void RecordHistogramEnum(std::string histogram_name,
41 base::HistogramBase::Sample sample, 42 base::HistogramBase::Sample sample,
42 base::HistogramBase::Sample bucket_count) { 43 base::HistogramBase::Sample bucket_count) {
43 DCHECK_LT(sample, bucket_count); 44 DCHECK_LT(sample, bucket_count);
44 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet( 45 base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet(
45 histogram_name, 1, bucket_count, bucket_count + 1, 46 histogram_name, 1, bucket_count, bucket_count + 1,
46 base::HistogramBase::kUmaTargetedHistogramFlag); 47 base::HistogramBase::kUmaTargetedHistogramFlag);
47 histogram_pointer->Add(sample); 48 histogram_pointer->Add(sample);
48 } 49 }
49 50
51 // Similar to UMA_HISTOGRAM_CUSTOM_TIMES but allows a dynamic histogram name.
52 void RecordHistogramTime(std::string histogram_name,
53 base::TimeDelta time_min,
54 base::TimeDelta time_max,
55 base::TimeDelta sample,
56 base::HistogramBase::Sample bucket_count) {
57 base::HistogramBase* histogram_pointer = base::Histogram::FactoryTimeGet(
58 histogram_name, time_min, time_max, bucket_count,
59 base::HistogramBase::kUmaTargetedHistogramFlag);
60 histogram_pointer->AddTime(sample);
61 }
62
50 // Time window for which we will record windowed PLTs from the last observed 63 // Time window for which we will record windowed PLTs from the last observed
51 // link rel=prefetch tag. This is not intended to be the same as the prerender 64 // link rel=prefetch tag. This is not intended to be the same as the prerender
52 // ttl, it's just intended to be a window during which a prerender has likely 65 // ttl, it's just intended to be a window during which a prerender has likely
53 // affected performance. 66 // affected performance.
54 const int kWindowDurationSeconds = 30; 67 const int kWindowDurationSeconds = 30;
55 68
56 std::string ComposeHistogramName(const std::string& prefix_type, 69 std::string ComposeHistogramName(const std::string& prefix_type,
57 const std::string& name) { 70 const std::string& name) {
58 if (prefix_type.empty()) 71 if (prefix_type.empty())
59 return std::string("Prerender.") + name; 72 return std::string("Prerender.") + name;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 DCHECK(thread_checker_.CalledOnValidThread()); 445 DCHECK(thread_checker_.CalledOnValidThread());
433 446
434 const int kMaxRedirectCount = 10; 447 const int kMaxRedirectCount = 10;
435 std::string histogram_base_name = base::StringPrintf( 448 std::string histogram_base_name = base::StringPrintf(
436 "NoStatePrefetch%sResourceRedirects", is_main_resource ? "Main" : "Sub"); 449 "NoStatePrefetch%sResourceRedirects", is_main_resource ? "Main" : "Sub");
437 std::string histogram_name = 450 std::string histogram_name =
438 GetHistogramName(origin, IsOriginWash(), histogram_base_name); 451 GetHistogramName(origin, IsOriginWash(), histogram_base_name);
439 RecordHistogramEnum(histogram_name, redirect_count, kMaxRedirectCount); 452 RecordHistogramEnum(histogram_name, redirect_count, kMaxRedirectCount);
440 } 453 }
441 454
455 void PrerenderHistograms::RecordFirstContentfulPaint(
456 Origin origin,
457 bool is_no_store,
458 base::TimeDelta time,
459 base::TimeDelta prefetch_age) {
460 DCHECK(thread_checker_.CalledOnValidThread());
461
462 std::string histogram_base_name;
463 if (prefetch_age.is_zero()) {
464 histogram_base_name = "NoStatePrefetchTTFCPReference";
465 } else {
466 DCHECK_NE(origin, ORIGIN_NONE);
467
468 RecordHistogramTime(GetHistogramName(origin, IsOriginWash(),
469 "Prerender.NoStatePrefetchAge"),
470 base::TimeDelta::FromMilliseconds(10),
471 base::TimeDelta::FromMinutes(30), prefetch_age, 50);
472
473 histogram_base_name = prefetch_age < base::TimeDelta::FromMinutes(
474 net::HttpCache::kPrefetchReuseMins)
475 ? "NoStatePrefetchTTFCPWithoutRevalidation"
mattcary 2016/09/14 12:33:21 So do we know positively that revalidation actuall
droger 2016/09/14 14:15:42 I assume that your concern is that being outside t
mattcary 2016/09/14 14:19:39 Yes, exactly.
476 : "NoStatePrefetchTTFCPWithRevalidation";
477 }
478
479 histogram_base_name += is_no_store ? "NoStore" : "Cacheable";
480
481 RecordHistogramTime(
482 GetHistogramName(origin, IsOriginWash(), histogram_base_name),
483 base::TimeDelta::FromMilliseconds(10), base::TimeDelta::FromMinutes(2),
484 time, 100);
485 }
486
442 bool PrerenderHistograms::IsOriginWash() const { 487 bool PrerenderHistograms::IsOriginWash() const {
443 if (!WithinWindow()) 488 if (!WithinWindow())
444 return false; 489 return false;
445 return origin_wash_; 490 return origin_wash_;
446 } 491 }
447 492
448 } // namespace prerender 493 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698