OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 if (bucketSizeList.isEmpty()) { | 111 if (bucketSizeList.isEmpty()) { |
112 bucketSizeList.resize(numberOfBuckets); | 112 bucketSizeList.resize(numberOfBuckets); |
113 | 113 |
114 float sizeOfNextBucket = 10000000.0; // First bucket size is roughly 10M
. | 114 float sizeOfNextBucket = 10000000.0; // First bucket size is roughly 10M
. |
115 const float largestBucketSize = 4000000000.0; // Roughly 4GB. | 115 const float largestBucketSize = 4000000000.0; // Roughly 4GB. |
116 // We scale with the Nth root of the ratio, so that we use all the buckt
es. | 116 // We scale with the Nth root of the ratio, so that we use all the buckt
es. |
117 const float scalingFactor = exp(log(largestBucketSize / sizeOfNextBucket
) / numberOfBuckets); | 117 const float scalingFactor = exp(log(largestBucketSize / sizeOfNextBucket
) / numberOfBuckets); |
118 | 118 |
119 size_t nextPowerOfTen = static_cast<size_t>(pow(10, floor(log10(sizeOfNe
xtBucket)) + 1) + 0.5); | 119 size_t nextPowerOfTen = static_cast<size_t>(pow(10, floor(log10(sizeOfNe
xtBucket)) + 1) + 0.5); |
120 size_t granularity = nextPowerOfTen / 1000; // We want 3 signficant digi
ts. | 120 size_t granularity = nextPowerOfTen / 1000; // We want 3 significant dig
its. |
121 | 121 |
122 for (int i = 0; i < numberOfBuckets; ++i) { | 122 for (int i = 0; i < numberOfBuckets; ++i) { |
123 size_t currentBucketSize = static_cast<size_t>(sizeOfNextBucket); | 123 size_t currentBucketSize = static_cast<size_t>(sizeOfNextBucket); |
124 bucketSizeList[i] = currentBucketSize - (currentBucketSize % granula
rity); | 124 bucketSizeList[i] = currentBucketSize - (currentBucketSize % granula
rity); |
125 | 125 |
126 sizeOfNextBucket *= scalingFactor; | 126 sizeOfNextBucket *= scalingFactor; |
127 if (sizeOfNextBucket >= nextPowerOfTen) { | 127 if (sizeOfNextBucket >= nextPowerOfTen) { |
128 if (std::numeric_limits<size_t>::max() / 10 <= nextPowerOfTen) { | 128 if (std::numeric_limits<size_t>::max() / 10 <= nextPowerOfTen) { |
129 nextPowerOfTen = std::numeric_limits<size_t>::max(); | 129 nextPowerOfTen = std::numeric_limits<size_t>::max(); |
130 } else { | 130 } else { |
(...skipping 18 matching lines...) Expand all Loading... |
149 | 149 |
150 MemoryInfo::MemoryInfo() | 150 MemoryInfo::MemoryInfo() |
151 { | 151 { |
152 if (RuntimeEnabledFeatures::preciseMemoryInfoEnabled()) | 152 if (RuntimeEnabledFeatures::preciseMemoryInfoEnabled()) |
153 getHeapSize(m_info); | 153 getHeapSize(m_info); |
154 else | 154 else |
155 HeapSizeCache::forCurrentThread().getCachedHeapSize(m_info); | 155 HeapSizeCache::forCurrentThread().getCachedHeapSize(m_info); |
156 } | 156 } |
157 | 157 |
158 } // namespace blink | 158 } // namespace blink |
OLD | NEW |