Converted timekeeping to timespan from miliseconds

This commit is contained in:
KevinMarquette
2017-02-06 22:57:40 -08:00
parent ce34bbf744
commit cc25b901fd
3 changed files with 17 additions and 17 deletions

View File

@@ -6,7 +6,7 @@ class MonitoredScript
hidden $lastNode = $null hidden $lastNode = $null
hidden $lastRecord = $null hidden $lastRecord = $null
[float]$ExecutionTime = 0 [timespan]$ExecutionTime = 0
[int]$LinesOfCode = 0 [int]$LinesOfCode = 0
MonitoredScript() MonitoredScript()
@@ -37,11 +37,11 @@ class MonitoredScript
# Calclate the delta in time # Calclate the delta in time
if($this.lastNode) if($this.lastNode)
{ {
$duration = $node.ElapsedMilliseconds - $this.lastNode.ElapsedMilliseconds $duration = $node.Elapsed - $this.lastNode.Elapsed
} }
else else
{ {
$duration = $node.ElapsedMilliseconds $duration = $node.Elapsed
} }
# The delta is how long the last command ran # The delta is how long the last command ran

View File

@@ -1,10 +1,10 @@
class ScriptLine class ScriptLine
{ {
[float] $Milliseconds = 0 [TimeSpan] $Duration = 0
[float] $HitCount = 0 [float] $HitCount = 0
[float] $Min = [float]::MaxValue [TimeSpan] $Min = [TimeSpan]::MaxValue
[float] $Max = [float]::MinValue [TimeSpan] $Max = [TimeSpan]::MinValue
[float] $Average = 0 [float] $Average = 0
[int] $LineNumber [int] $LineNumber
[string] $Path [string] $Path
@@ -26,21 +26,21 @@ class ScriptLine
} }
[void]AddExecutionTime([float]$Milliseconds) [void]AddExecutionTime([timespan]$Duration)
{ {
$this.LastNode.Milliseconds = $Milliseconds $this.LastNode.Duration = $Duration
$this.Milliseconds += $Milliseconds $this.Duration += $Duration
$this.HitCount += 1 $this.HitCount += 1
$this.Average = $this.Milliseconds / $this.HitCount $this.Average = $this.Duration.Milliseconds / $this.HitCount
if($Milliseconds -lt $this.Min) if($Duration -lt $this.Min)
{ {
$this.Min = $Milliseconds $this.Min = $Duration
} }
if($Milliseconds -gt $this.Max) if($Duration -gt $this.Max)
{ {
$this.Max = $Milliseconds $this.Max = $Duration
} }
} }
@@ -52,7 +52,7 @@ class ScriptLine
[void] Clear() [void] Clear()
{ {
$this.Milliseconds = 0 $this.Duration = [timespan]::Zero
$this.HitCount = 0 $this.HitCount = 0
$this.Average = 0 $this.Average = 0
$this.LastNode = $null $this.LastNode = $null
@@ -62,7 +62,7 @@ class ScriptLine
[string] ToString() [string] ToString()
{ {
$values = @( $values = @(
$this.Milliseconds $this.Duration.Milliseconds
$this.HitCount $this.HitCount
$this.Average $this.Average
$this.LineNumber $this.LineNumber

View File

@@ -13,7 +13,7 @@ class ScriptProfiler {
{ {
[ScriptProfiler]::Queue.Enqueue(@{ [ScriptProfiler]::Queue.Enqueue(@{
Breakpoint = $InputObject Breakpoint = $InputObject
ElapsedMilliseconds = [ScriptProfiler]::Timer.ElapsedMilliseconds Elapsed = [ScriptProfiler]::Timer.Elapsed
}) })
} }
} }