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

Side by Side Diff: content/browser/download/download_stats.cc

Issue 10695062: Improve download performance statistics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid division by zero errors. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/download/download_stats.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/download/download_stats.h" 5 #include "content/browser/download/download_stats.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "content/browser/download/download_resource_handler.h" 9 #include "content/browser/download/download_resource_handler.h"
10 #include "content/public/browser/download_interrupt_reasons.h" 10 #include "content/public/browser/download_interrupt_reasons.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 size, 299 size,
300 0/*min*/, 300 0/*min*/,
301 (1 << 10)/*max*/, 301 (1 << 10)/*max*/,
302 64/*num_buckets*/); 302 64/*num_buckets*/);
303 } 303 }
304 304
305 void RecordContiguousWriteTime(base::TimeDelta time_blocked) { 305 void RecordContiguousWriteTime(base::TimeDelta time_blocked) {
306 UMA_HISTOGRAM_TIMES("Download.FileThreadBlockedTime", time_blocked); 306 UMA_HISTOGRAM_TIMES("Download.FileThreadBlockedTime", time_blocked);
307 } 307 }
308 308
309 void RecordNetworkBandwidth(size_t length, 309 // Record what percentage of the time we have the network flow controlled.
310 base::TimeDelta elapsed_time, 310 void RecordNetworkBlockage(base::TimeDelta resource_handler_lifetime,
311 base::TimeDelta paused_time) { 311 base::TimeDelta resource_handler_blocked_time) {
312 size_t non_pause_time_ms = (elapsed_time - paused_time).InMilliseconds(); 312 int percentage = 0;
313 if (0u == non_pause_time_ms) 313 // Avoid division by zero errors.
314 non_pause_time_ms = 1; 314 if (resource_handler_blocked_time != base::TimeDelta()) {
315 percentage =
316 resource_handler_blocked_time * 100 / resource_handler_lifetime;
317 }
315 318
316 // Note that this will be somewhat higher than sustainable network 319 UMA_HISTOGRAM_COUNTS_100("Download.ResourceHandlerBlockedPercentage",
317 // bandwidth because of buffering in the kernel during pauses. 320 percentage);
318 // Using Bytes/s rather than bits/s so that this value is easily
319 // comparable with BandwidthOverall and BandwidthDisk.
320 UMA_HISTOGRAM_CUSTOM_COUNTS(
321 "Download.BandwidthNetworkBytesPerSecond",
322 (1000 * length / non_pause_time_ms),
323 1, 100000000, 50);
324 } 321 }
325 322
326 void RecordFileBandwidth(size_t length, 323 void RecordFileBandwidth(size_t length,
327 base::TimeDelta disk_write_time, 324 base::TimeDelta disk_write_time,
328 base::TimeDelta elapsed_time) { 325 base::TimeDelta elapsed_time) {
329 size_t elapsed_time_ms = elapsed_time.InMilliseconds(); 326 size_t elapsed_time_ms = elapsed_time.InMilliseconds();
330 if (0u == elapsed_time_ms) 327 if (0u == elapsed_time_ms)
331 elapsed_time_ms = 1; 328 elapsed_time_ms = 1;
332 size_t disk_write_time_ms = disk_write_time.InMilliseconds(); 329 size_t disk_write_time_ms = disk_write_time.InMilliseconds();
333 if (0u == disk_write_time_ms) 330 if (0u == disk_write_time_ms)
334 disk_write_time_ms = 1; 331 disk_write_time_ms = 1;
335 332
336 UMA_HISTOGRAM_CUSTOM_COUNTS( 333 UMA_HISTOGRAM_CUSTOM_COUNTS(
337 "Download.BandwidthOverallBytesPerSecond", 334 "Download.BandwidthOverallBytesPerSecond",
338 (1000 * length / elapsed_time_ms), 1, 50000000, 50); 335 (1000 * length / elapsed_time_ms), 1, 50000000, 50);
339 UMA_HISTOGRAM_CUSTOM_COUNTS( 336 UMA_HISTOGRAM_CUSTOM_COUNTS(
340 "Download.BandwidthDiskBytesPerSecond", 337 "Download.BandwidthDiskBytesPerSecond",
341 (1000 * length / disk_write_time_ms), 1, 50000000, 50); 338 (1000 * length / disk_write_time_ms), 1, 50000000, 50);
339 UMA_HISTOGRAM_COUNTS_100("Download.DiskBandwidthUsedPercentage",
340 disk_write_time_ms * 100 / elapsed_time_ms);
342 } 341 }
343 342
344 void RecordSavePackageEvent(SavePackageEvent event) { 343 void RecordSavePackageEvent(SavePackageEvent event) {
345 UMA_HISTOGRAM_ENUMERATION("Download.SavePackage", 344 UMA_HISTOGRAM_ENUMERATION("Download.SavePackage",
346 event, 345 event,
347 SAVE_PACKAGE_LAST_ENTRY); 346 SAVE_PACKAGE_LAST_ENTRY);
348 } 347 }
349 348
350 } // namespace download_stats 349 } // namespace download_stats
OLDNEW
« no previous file with comments | « content/browser/download/download_stats.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698