Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/download/download_stats.h" | 5 #include "content/browser/download/download_stats.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/histogram_functions.h" | 8 #include "base/metrics/histogram_functions.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 "Download.ParallelizableDownloadBandwidth." | 811 "Download.ParallelizableDownloadBandwidth." |
| 812 "WithoutParallelRequests", | 812 "WithoutParallelRequests", |
| 813 bandwidth_without_parallel_streams); | 813 bandwidth_without_parallel_streams); |
| 814 } | 814 } |
| 815 } | 815 } |
| 816 | 816 |
| 817 if (!uses_parallel_requests) | 817 if (!uses_parallel_requests) |
| 818 return; | 818 return; |
| 819 | 819 |
| 820 if (bytes_downloaded_with_parallel_streams > 0) { | 820 if (bytes_downloaded_with_parallel_streams > 0) { |
| 821 int64_t bandwidth_with_parallel_streams = CalculateBandwidthBytesPerSecond( | |
| 822 bytes_downloaded_with_parallel_streams, time_with_parallel_streams); | |
| 821 RecordBandwidthMetric( | 823 RecordBandwidthMetric( |
| 822 "Download.ParallelizableDownloadBandwidth." | 824 "Download.ParallelizableDownloadBandwidth." |
| 823 "WithParallelRequestsMultipleStreams", | 825 "WithParallelRequestsMultipleStreams", |
| 824 CalculateBandwidthBytesPerSecond(bytes_downloaded_with_parallel_streams, | 826 bandwidth_with_parallel_streams); |
| 825 time_with_parallel_streams)); | 827 |
| 828 if (bandwidth_without_parallel_streams) { | |
| 829 int bandwidth_ratio_percentage = | |
| 830 (100.0 * bandwidth_with_parallel_streams) / | |
| 831 bandwidth_without_parallel_streams; | |
| 832 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 833 "Download.ParallelDownload.BandwidthRatioPercentage", | |
| 834 bandwidth_ratio_percentage, 0, 400, 101); | |
| 835 base::TimeDelta total_time = | |
| 836 time_with_parallel_streams + time_without_parallel_streams; | |
| 837 size_t total_size = bytes_downloaded_with_parallel_streams + | |
| 838 bytes_downloaded_without_parallel_streams; | |
| 839 base::TimeDelta improved_time = base::TimeDelta::FromSecondsD( | |
| 840 static_cast<double>(total_size) / bandwidth_with_parallel_streams); | |
| 841 int time_ratio_percentage = | |
|
qinmin
2017/05/10 18:46:47
This doesn't seem right.
When we say that parallel
xingliu
2017/05/10 20:08:06
Done. Makes sense.
| |
| 842 100.0 * improved_time.InSecondsF() / total_time.InSecondsF(); | |
| 843 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 844 "Download.ParallelDownload.TotalTimeRatioPercentage", | |
| 845 time_ratio_percentage, 0, 200, 101); | |
| 846 } | |
| 826 } | 847 } |
| 827 | 848 |
| 828 base::TimeDelta time_saved; | 849 base::TimeDelta time_saved; |
| 829 if (bandwidth_without_parallel_streams > 0) { | 850 if (bandwidth_without_parallel_streams > 0) { |
| 830 time_saved = base::TimeDelta::FromMilliseconds( | 851 time_saved = base::TimeDelta::FromMilliseconds( |
| 831 1000.0 * bytes_downloaded_with_parallel_streams / | 852 1000.0 * bytes_downloaded_with_parallel_streams / |
| 832 bandwidth_without_parallel_streams) - | 853 bandwidth_without_parallel_streams) - |
| 833 time_with_parallel_streams; | 854 time_with_parallel_streams; |
| 834 } | 855 } |
| 835 int kMillisecondsPerHour = | 856 int kMillisecondsPerHour = |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 } | 955 } |
| 935 | 956 |
| 936 void RecordDownloadHttpResponseCode(int response_code) { | 957 void RecordDownloadHttpResponseCode(int response_code) { |
| 937 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 958 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
| 938 "Download.HttpResponseCode", | 959 "Download.HttpResponseCode", |
| 939 net::HttpUtil::MapStatusCodeForHistogram(response_code), | 960 net::HttpUtil::MapStatusCodeForHistogram(response_code), |
| 940 net::HttpUtil::GetStatusCodesForHistogram()); | 961 net::HttpUtil::GetStatusCodesForHistogram()); |
| 941 } | 962 } |
| 942 | 963 |
| 943 } // namespace content | 964 } // namespace content |
| OLD | NEW |