mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-08 17:24:49 +00:00
Method for profiling each step in an enumerable
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ICD.Common.Properties;
|
||||
#if SIMPLSHARP
|
||||
using Crestron.SimplSharp;
|
||||
@@ -128,6 +129,22 @@ namespace ICD.Common.Utils.Timers
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Profiles getting each item from the enumerable.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="enumerable"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> Profile<T>(IEnumerable<T> enumerable, string name)
|
||||
{
|
||||
using (IEnumerator<T> enumerator = enumerable.GetEnumerator())
|
||||
{
|
||||
while (Profile(() => enumerator.MoveNext(), name))
|
||||
yield return enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintProfile(IcdStopwatch stopwatch, string name)
|
||||
{
|
||||
long elapsed = stopwatch.ElapsedMilliseconds;
|
||||
|
||||
Reference in New Issue
Block a user