Added per-line execution metadata

This commit is contained in:
KevinMarquette
2017-02-06 21:43:43 -08:00
parent 068d1e129d
commit 337c4f457d
2 changed files with 26 additions and 0 deletions

View File

@@ -38,6 +38,9 @@ class MonitoredScript
$lineNumber = $node.Breakpoint.Line - 1
$record = $this.Line[$lineNumber]
$record.AddExecution($node)
# Calclate the delta in time
if($this.lastNode)
{
$duration = $node.ElapsedMilliseconds - $this.lastNode.ElapsedMilliseconds
@@ -47,6 +50,7 @@ class MonitoredScript
$duration = $node.ElapsedMilliseconds
}
# The delta is how long the last command ran
if($this.lastRecord)
{
$this.lastRecord.AddExecutionTime($duration)

View File

@@ -9,10 +9,17 @@ class ScriptLine
[int] $LineNumber
[string] $Path
[string] $Text
[System.Collections.ArrayList]$Executions
hidden [hashtable]$LastNode = $null
ScriptLine()
{
$Executions = New-Object 'System.Collections.ArrayList'
}
[void]AddExecutionTime([float]$Milliseconds)
{
$this.LastNode.Milliseconds = $Milliseconds
$this.Milliseconds += $Milliseconds
$this.HitCount += 1
$this.Average = $this.Milliseconds / $this.HitCount
@@ -28,6 +35,21 @@ class ScriptLine
}
}
[void] AddExecution([hashtable]$node)
{
$this.Executions.Add($node)
$this.LastNode = $node
}
[void] Clear()
{
$this.Milliseconds = 0
$this.HitCount = 0
$this.Average = 0
$this.LastNode = $null
$this.Executions.Clear()
}
[string] ToString()
{
$values = @(