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 "net/disk_cache/blockfile/backend_impl.h" | 5 #include "net/disk_cache/blockfile/backend_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 } | 477 } |
478 | 478 |
479 int current_size = data_->header.num_bytes / (1024 * 1024); | 479 int current_size = data_->header.num_bytes / (1024 * 1024); |
480 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; | 480 int64 total_hours = stats_.GetCounter(Stats::TIMER) / 120; |
481 int64 no_use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; | 481 int64 no_use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; |
482 int64 use_hours = total_hours - no_use_hours; | 482 int64 use_hours = total_hours - no_use_hours; |
483 | 483 |
484 if (!cache_entry) { | 484 if (!cache_entry) { |
485 CACHE_UMA(AGE_MS, "OpenTime.Miss", 0, start); | 485 CACHE_UMA(AGE_MS, "OpenTime.Miss", 0, start); |
486 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Miss", 0, current_size); | 486 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Miss", 0, current_size); |
487 CACHE_UMA(HOURS, "AllOpenByTotalHours.Miss", 0, total_hours); | 487 CACHE_UMA(HOURS, "AllOpenByTotalHours.Miss", 0, |
488 CACHE_UMA(HOURS, "AllOpenByUseHours.Miss", 0, use_hours); | 488 static_cast<base::HistogramBase::Sample>(total_hours)); |
| 489 CACHE_UMA(HOURS, "AllOpenByUseHours.Miss", 0, |
| 490 static_cast<base::HistogramBase::Sample>(use_hours)); |
489 stats_.OnEvent(Stats::OPEN_MISS); | 491 stats_.OnEvent(Stats::OPEN_MISS); |
490 return NULL; | 492 return NULL; |
491 } | 493 } |
492 | 494 |
493 eviction_.OnOpenEntry(cache_entry); | 495 eviction_.OnOpenEntry(cache_entry); |
494 entry_count_++; | 496 entry_count_++; |
495 | 497 |
496 Trace("Open hash 0x%x end: 0x%x", hash, | 498 Trace("Open hash 0x%x end: 0x%x", hash, |
497 cache_entry->entry()->address().value()); | 499 cache_entry->entry()->address().value()); |
498 CACHE_UMA(AGE_MS, "OpenTime", 0, start); | 500 CACHE_UMA(AGE_MS, "OpenTime", 0, start); |
499 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size); | 501 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size); |
500 CACHE_UMA(HOURS, "AllOpenByTotalHours.Hit", 0, total_hours); | 502 CACHE_UMA(HOURS, "AllOpenByTotalHours.Hit", 0, |
501 CACHE_UMA(HOURS, "AllOpenByUseHours.Hit", 0, use_hours); | 503 static_cast<base::HistogramBase::Sample>(total_hours)); |
| 504 CACHE_UMA(HOURS, "AllOpenByUseHours.Hit", 0, |
| 505 static_cast<base::HistogramBase::Sample>(use_hours)); |
502 stats_.OnEvent(Stats::OPEN_HIT); | 506 stats_.OnEvent(Stats::OPEN_HIT); |
503 web_fonts_histogram::RecordCacheHit(cache_entry); | 507 web_fonts_histogram::RecordCacheHit(cache_entry); |
504 SIMPLE_STATS_COUNTER("disk_cache.hit"); | 508 SIMPLE_STATS_COUNTER("disk_cache.hit"); |
505 return cache_entry; | 509 return cache_entry; |
506 } | 510 } |
507 | 511 |
508 EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { | 512 EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { |
509 if (disabled_ || key.empty()) | 513 if (disabled_ || key.empty()) |
510 return NULL; | 514 return NULL; |
511 | 515 |
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 } | 1883 } |
1880 | 1884 |
1881 // This is an up to date client that will report FirstEviction() data. After | 1885 // This is an up to date client that will report FirstEviction() data. After |
1882 // that event, start reporting this: | 1886 // that event, start reporting this: |
1883 | 1887 |
1884 CACHE_UMA(HOURS, "TotalTime", 0, static_cast<int>(total_hours)); | 1888 CACHE_UMA(HOURS, "TotalTime", 0, static_cast<int>(total_hours)); |
1885 // For any bin in HitRatioByTotalTime, the hit ratio of caches of that total | 1889 // For any bin in HitRatioByTotalTime, the hit ratio of caches of that total |
1886 // time is the ratio of that bin's total count to the count in the same bin in | 1890 // time is the ratio of that bin's total count to the count in the same bin in |
1887 // the TotalTime histogram. | 1891 // the TotalTime histogram. |
1888 if (base::RandInt(0, 99) < hit_ratio_as_percentage) | 1892 if (base::RandInt(0, 99) < hit_ratio_as_percentage) |
1889 CACHE_UMA(HOURS, "HitRatioByTotalTime", 0, implicit_cast<int>(total_hours)); | 1893 CACHE_UMA(HOURS, "HitRatioByTotalTime", 0, static_cast<int>(total_hours)); |
1890 | 1894 |
1891 int64 use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; | 1895 int64 use_hours = stats_.GetCounter(Stats::LAST_REPORT_TIMER) / 120; |
1892 stats_.SetCounter(Stats::LAST_REPORT_TIMER, stats_.GetCounter(Stats::TIMER)); | 1896 stats_.SetCounter(Stats::LAST_REPORT_TIMER, stats_.GetCounter(Stats::TIMER)); |
1893 | 1897 |
1894 // We may see users with no use_hours at this point if this is the first time | 1898 // We may see users with no use_hours at this point if this is the first time |
1895 // we are running this code. | 1899 // we are running this code. |
1896 if (use_hours) | 1900 if (use_hours) |
1897 use_hours = total_hours - use_hours; | 1901 use_hours = total_hours - use_hours; |
1898 | 1902 |
1899 if (!use_hours || !GetEntryCount() || !data_->header.num_bytes) | 1903 if (!use_hours || !GetEntryCount() || !data_->header.num_bytes) |
1900 return; | 1904 return; |
1901 | 1905 |
1902 CACHE_UMA(HOURS, "UseTime", 0, static_cast<int>(use_hours)); | 1906 CACHE_UMA(HOURS, "UseTime", 0, static_cast<int>(use_hours)); |
1903 // For any bin in HitRatioByUseTime, the hit ratio of caches of that use time | 1907 // For any bin in HitRatioByUseTime, the hit ratio of caches of that use time |
1904 // is the ratio of that bin's total count to the count in the same bin in the | 1908 // is the ratio of that bin's total count to the count in the same bin in the |
1905 // UseTime histogram. | 1909 // UseTime histogram. |
1906 if (base::RandInt(0, 99) < hit_ratio_as_percentage) | 1910 if (base::RandInt(0, 99) < hit_ratio_as_percentage) |
1907 CACHE_UMA(HOURS, "HitRatioByUseTime", 0, implicit_cast<int>(use_hours)); | 1911 CACHE_UMA(HOURS, "HitRatioByUseTime", 0, static_cast<int>(use_hours)); |
1908 CACHE_UMA(PERCENTAGE, "HitRatio", 0, hit_ratio_as_percentage); | 1912 CACHE_UMA(PERCENTAGE, "HitRatio", 0, hit_ratio_as_percentage); |
1909 | 1913 |
1910 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; | 1914 int64 trim_rate = stats_.GetCounter(Stats::TRIM_ENTRY) / use_hours; |
1911 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); | 1915 CACHE_UMA(COUNTS, "TrimRate", 0, static_cast<int>(trim_rate)); |
1912 | 1916 |
1913 int avg_size = data_->header.num_bytes / GetEntryCount(); | 1917 int avg_size = data_->header.num_bytes / GetEntryCount(); |
1914 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); | 1918 CACHE_UMA(COUNTS, "EntrySize", 0, avg_size); |
1915 CACHE_UMA(COUNTS, "EntriesFull", 0, data_->header.num_entries); | 1919 CACHE_UMA(COUNTS, "EntriesFull", 0, data_->header.num_entries); |
1916 | 1920 |
1917 CACHE_UMA(PERCENTAGE, "IndexLoad", 0, | 1921 CACHE_UMA(PERCENTAGE, "IndexLoad", 0, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2080 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2084 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2081 total_memory = kMaxBuffersSize; | 2085 total_memory = kMaxBuffersSize; |
2082 | 2086 |
2083 done = true; | 2087 done = true; |
2084 } | 2088 } |
2085 | 2089 |
2086 return static_cast<int>(total_memory); | 2090 return static_cast<int>(total_memory); |
2087 } | 2091 } |
2088 | 2092 |
2089 } // namespace disk_cache | 2093 } // namespace disk_cache |
OLD | NEW |