mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 20:47:24 +00:00
Method for profiling each step in an enumerable
This commit is contained in:
parent
cffe850bd7
commit
02ecff187d
1 changed files with 17 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using ICD.Common.Properties;
|
using ICD.Common.Properties;
|
||||||
#if SIMPLSHARP
|
#if SIMPLSHARP
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
@ -128,6 +129,22 @@ namespace ICD.Common.Utils.Timers
|
||||||
return output;
|
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)
|
private static void PrintProfile(IcdStopwatch stopwatch, string name)
|
||||||
{
|
{
|
||||||
long elapsed = stopwatch.ElapsedMilliseconds;
|
long elapsed = stopwatch.ElapsedMilliseconds;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue