OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 | 6 |
7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 , m_pruneTimeStamp(0.0) | 92 , m_pruneTimeStamp(0.0) |
93 , m_pruneFrameTimeStamp(0.0) | 93 , m_pruneFrameTimeStamp(0.0) |
94 , m_lastFramePaintTimeStamp(0.0) | 94 , m_lastFramePaintTimeStamp(0.0) |
95 , m_capacity(cDefaultCacheCapacity) | 95 , m_capacity(cDefaultCacheCapacity) |
96 , m_minDeadCapacity(0) | 96 , m_minDeadCapacity(0) |
97 , m_maxDeadCapacity(cDefaultCacheCapacity) | 97 , m_maxDeadCapacity(cDefaultCacheCapacity) |
98 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault
CacheCapacity) | 98 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault
CacheCapacity) |
99 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) | 99 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) |
100 , m_liveSize(0) | 100 , m_liveSize(0) |
101 , m_deadSize(0) | 101 , m_deadSize(0) |
102 #ifdef MEMORY_CACHE_STATS | |
103 , m_statsTimer(this, &MemoryCache::dumpStats) | |
104 #endif | |
105 { | 102 { |
106 MemoryCacheDumpProvider::instance()->setMemoryCache(this); | 103 MemoryCacheDumpProvider::instance()->setMemoryCache(this); |
107 if (ProcessHeap::isLowEndDevice()) | 104 if (ProcessHeap::isLowEndDevice()) |
108 MemoryCoordinator::instance().registerClient(this); | 105 MemoryCoordinator::instance().registerClient(this); |
109 #ifdef MEMORY_CACHE_STATS | |
110 const double statsIntervalInSeconds = 15; | |
111 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE); | |
112 #endif | |
113 } | 106 } |
114 | 107 |
115 MemoryCache* MemoryCache::create() | 108 MemoryCache* MemoryCache::create() |
116 { | 109 { |
117 return new MemoryCache; | 110 return new MemoryCache; |
118 } | 111 } |
119 | 112 |
120 MemoryCache::~MemoryCache() | 113 MemoryCache::~MemoryCache() |
121 { | 114 { |
122 if (m_prunePending) | 115 if (m_prunePending) |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 | 732 |
740 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) | 733 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) |
741 { | 734 { |
742 MemoryCacheEntry* ex = getEntryForResource(x); | 735 MemoryCacheEntry* ex = getEntryForResource(x); |
743 MemoryCacheEntry* ey = getEntryForResource(y); | 736 MemoryCacheEntry* ey = getEntryForResource(y); |
744 ASSERT(ex); | 737 ASSERT(ex); |
745 ASSERT(ey); | 738 ASSERT(ey); |
746 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo
unt, y->size()); | 739 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo
unt, y->size()); |
747 } | 740 } |
748 | 741 |
749 #ifdef MEMORY_CACHE_STATS | |
750 | |
751 void MemoryCache::dumpStats(TimerBase*) | |
752 { | |
753 Statistics s = getStatistics(); | |
754 printf("%-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "
DecodedSize"); | |
755 printf("%-13s %-13s %-13s %-13s %-13s\n", "-------------", "-------------",
"-------------", "-------------", "-------------"); | |
756 printf("%-13s %13zu %13zu %13zu %13zu\n", "Images", s.images.count, s.images
.size, s.images.liveSize, s.images.decodedSize); | |
757 printf("%-13s %13zu %13zu %13zu %13zu\n", "CSS", s.cssStyleSheets.count, s.c
ssStyleSheets.size, s.cssStyleSheets.liveSize, s.cssStyleSheets.decodedSize); | |
758 printf("%-13s %13zu %13zu %13zu %13zu\n", "XSL", s.xslStyleSheets.count, s.x
slStyleSheets.size, s.xslStyleSheets.liveSize, s.xslStyleSheets.decodedSize); | |
759 printf("%-13s %13zu %13zu %13zu %13zu\n", "JavaScript", s.scripts.count, s.s
cripts.size, s.scripts.liveSize, s.scripts.decodedSize); | |
760 printf("%-13s %13zu %13zu %13zu %13zu\n", "Fonts", s.fonts.count, s.fonts.si
ze, s.fonts.liveSize, s.fonts.decodedSize); | |
761 printf("%-13s %13zu %13zu %13zu %13zu\n", "Other", s.other.count, s.other.si
ze, s.other.liveSize, s.other.decodedSize); | |
762 printf("%-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------"
, "-------------", "-------------", "-------------"); | |
763 | |
764 printf("Duplication of encoded data from data URLs\n"); | |
765 printf("%-13s %13zu of %13zu\n", "Images", s.images.encodedSizeDuplicate
dInDataURLs, s.images.encodedSize); | |
766 printf("%-13s %13zu of %13zu\n", "CSS", s.cssStyleSheets.encodedSizeD
uplicatedInDataURLs, s.cssStyleSheets.encodedSize); | |
767 printf("%-13s %13zu of %13zu\n", "XSL", s.xslStyleSheets.encodedSizeD
uplicatedInDataURLs, s.xslStyleSheets.encodedSize); | |
768 printf("%-13s %13zu of %13zu\n", "JavaScript", s.scripts.encodedSizeDuplicat
edInDataURLs, s.scripts.encodedSize); | |
769 printf("%-13s %13zu of %13zu\n", "Fonts", s.fonts.encodedSizeDuplicated
InDataURLs, s.fonts.encodedSize); | |
770 printf("%-13s %13zu of %13zu\n", "Other", s.other.encodedSizeDuplicated
InDataURLs, s.other.encodedSize); | |
771 } | |
772 | |
773 void MemoryCache::dumpLRULists(bool includeLive) const | |
774 { | |
775 printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded
, Access count, Referenced, isPurgeable):\n"); | |
776 | |
777 int size = m_allResources.size(); | |
778 for (int i = size - 1; i >= 0; i--) { | |
779 printf("\n\nList %d: ", i); | |
780 MemoryCacheEntry* current = m_allResources[i].m_tail; | |
781 while (current) { | |
782 Resource* currentResource = current->resource(); | |
783 if (includeLive || !currentResource->isAlive()) | |
784 printf("(%.1fK, %.1fK, %uA, %dR); ", currentResource->decodedSiz
e() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSize()
) / 1024.0f, current->m_accessCount, currentResource->isAlive()); | |
785 | |
786 current = current->m_previousInAllResourcesList; | |
787 } | |
788 } | |
789 } | |
790 | |
791 #endif // MEMORY_CACHE_STATS | |
792 | |
793 } // namespace blink | 742 } // namespace blink |
OLD | NEW |