Added per-line execution metadata
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 = @(
|
||||
|
||||
Reference in New Issue
Block a user