Added per-line execution metadata
This commit is contained in:
@@ -38,6 +38,9 @@ class MonitoredScript
|
|||||||
$lineNumber = $node.Breakpoint.Line - 1
|
$lineNumber = $node.Breakpoint.Line - 1
|
||||||
$record = $this.Line[$lineNumber]
|
$record = $this.Line[$lineNumber]
|
||||||
|
|
||||||
|
$record.AddExecution($node)
|
||||||
|
|
||||||
|
# Calclate the delta in time
|
||||||
if($this.lastNode)
|
if($this.lastNode)
|
||||||
{
|
{
|
||||||
$duration = $node.ElapsedMilliseconds - $this.lastNode.ElapsedMilliseconds
|
$duration = $node.ElapsedMilliseconds - $this.lastNode.ElapsedMilliseconds
|
||||||
@@ -47,6 +50,7 @@ class MonitoredScript
|
|||||||
$duration = $node.ElapsedMilliseconds
|
$duration = $node.ElapsedMilliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The delta is how long the last command ran
|
||||||
if($this.lastRecord)
|
if($this.lastRecord)
|
||||||
{
|
{
|
||||||
$this.lastRecord.AddExecutionTime($duration)
|
$this.lastRecord.AddExecutionTime($duration)
|
||||||
|
|||||||
@@ -9,10 +9,17 @@ class ScriptLine
|
|||||||
[int] $LineNumber
|
[int] $LineNumber
|
||||||
[string] $Path
|
[string] $Path
|
||||||
[string] $Text
|
[string] $Text
|
||||||
|
[System.Collections.ArrayList]$Executions
|
||||||
|
hidden [hashtable]$LastNode = $null
|
||||||
|
|
||||||
|
ScriptLine()
|
||||||
|
{
|
||||||
|
$Executions = New-Object 'System.Collections.ArrayList'
|
||||||
|
}
|
||||||
|
|
||||||
[void]AddExecutionTime([float]$Milliseconds)
|
[void]AddExecutionTime([float]$Milliseconds)
|
||||||
{
|
{
|
||||||
|
$this.LastNode.Milliseconds = $Milliseconds
|
||||||
$this.Milliseconds += $Milliseconds
|
$this.Milliseconds += $Milliseconds
|
||||||
$this.HitCount += 1
|
$this.HitCount += 1
|
||||||
$this.Average = $this.Milliseconds / $this.HitCount
|
$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()
|
[string] ToString()
|
||||||
{
|
{
|
||||||
$values = @(
|
$values = @(
|
||||||
|
|||||||
Reference in New Issue
Block a user