/// <summary> /// Gets the mean consumed memory. /// </summary> /// <param name="memory">An instance of memory wacher implementation.</param> /// <returns>The mean consumed memory during the memory performance evaluation.</returns> /// <seealso cref="IMemoryWatcher"/> /// <exception cref="T:System.OverflowException">Throws when the memory values generates a long overflow.</exception> public static long GetMeanMemory(this IMemoryWatcher memory) { var measuredMemory = memory.GetMeasuredMemory(); long memoryValuesSummed; checked { memoryValuesSummed = measuredMemory.Aggregate(0L, (previous, mm) => previous + mm); } return(memoryValuesSummed / measuredMemory.Count); }
/// <summary> /// Gets the maximun consumed memory. /// </summary> /// <param name="memory">An instance of memory wacher implementation</param> /// <returns>The maximun consumed memory during the memory performance evaluation.</returns> /// <seealso cref="IMemoryWatcher"/> public static long GetMaxMemory(this IMemoryWatcher memory) => memory.GetMeasuredMemory().DefaultIfEmpty().Max();