mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 12:07:05 +00:00
fix: Slightly more accurate profile times
This commit is contained in:
parent
ca10f049e5
commit
9cdb590d9f
1 changed files with 8 additions and 11 deletions
|
|
@ -106,7 +106,7 @@ namespace ICD.Common.Utils.Timers
|
|||
|
||||
IcdStopwatch stopwatch = StartNew();
|
||||
action();
|
||||
PrintProfile(stopwatch, name);
|
||||
PrintProfile(stopwatch.ElapsedTicks, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -122,12 +122,9 @@ namespace ICD.Common.Utils.Timers
|
|||
if (func == null)
|
||||
throw new ArgumentNullException("func");
|
||||
|
||||
T output = default(T);
|
||||
|
||||
Profile(() =>
|
||||
{
|
||||
output = func();
|
||||
}, name);
|
||||
IcdStopwatch stopwatch = StartNew();
|
||||
T output = func();
|
||||
PrintProfile(stopwatch.ElapsedTicks, name);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
@ -213,7 +210,7 @@ namespace ICD.Common.Utils.Timers
|
|||
{
|
||||
if (eventHandler == null)
|
||||
{
|
||||
PrintProfile(new IcdStopwatch(), string.Format("{0} - No invocations", name));
|
||||
PrintProfile(0, string.Format("{0} - No invocations", name));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +241,7 @@ namespace ICD.Common.Utils.Timers
|
|||
{
|
||||
if (eventHandler == null)
|
||||
{
|
||||
PrintProfile(new IcdStopwatch(), string.Format("{0} - No invocations", name));
|
||||
PrintProfile(0, string.Format("{0} - No invocations", name));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -262,9 +259,9 @@ namespace ICD.Common.Utils.Timers
|
|||
}
|
||||
}
|
||||
|
||||
private static void PrintProfile(IcdStopwatch stopwatch, string name)
|
||||
private static void PrintProfile(long ticks, string name)
|
||||
{
|
||||
float elapsed = stopwatch.ElapsedTicks / (float)TimeSpan.TicksPerMillisecond;
|
||||
float elapsed = ticks / (float)TimeSpan.TicksPerMillisecond;
|
||||
|
||||
eConsoleColor color = eConsoleColor.Green;
|
||||
if (elapsed >= YELLOW_MILLISECONDS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue