Class SampledSizeEstimator
Estimates the total size of a large collection by sizing a bounded sample and extrapolating across the full count, so a per-tick size diagnostic does not pay an O(n) cost on very large caches.
Inheritance
object
Namespace: Umbraco.Cms.Core.Cache
Assembly: Umbraco.Core.dll
Syntax
public static class SampledSizeEstimator
Methods
View SourceEstimate<T>(int, IEnumerable<T>, Func<T, long>, int)
Sizes up to maxSample items from items and scales the sampled
average across count.
Declaration
public static long Estimate<T>(int count, IEnumerable<T> items, Func<T, long> sizeOf, int maxSample = 1000)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | The total number of items in the collection. |
| IEnumerable<T> | items | The items to sample (enumerated lazily; only the first |
| Func<T, long> | sizeOf | Returns the approximate size, in bytes, of a single item. |
| int | maxSample | The maximum number of items to size before extrapolating. |
Returns
| Type | Description |
|---|---|
| long | The extrapolated approximate total size in bytes. |
Type Parameters
| Name | Description |
|---|---|
| T | The item type. |