From 480543d41d0f1d229191fb4a3bc0ef95f6f0d741 Mon Sep 17 00:00:00 2001 From: SteveGTR Date: Mon, 28 Jan 2019 15:33:19 -0500 Subject: [PATCH] Added static LastNode The LastNode is used with the changes to Get-Chronometer to properly calculated data for the last line in the file. For example the following script's last line will not get any timing information because of a last record bug in the existing code: Start-Sleep 5 Start-Sleep 10 --- Chronometer/Classes/ScriptProfiler.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Chronometer/Classes/ScriptProfiler.ps1 b/Chronometer/Classes/ScriptProfiler.ps1 index 5f600fc..ba8919e 100644 --- a/Chronometer/Classes/ScriptProfiler.ps1 +++ b/Chronometer/Classes/ScriptProfiler.ps1 @@ -3,6 +3,8 @@ class ScriptProfiler { static [System.Collections.Queue] $Queue static [System.Diagnostics.Stopwatch] $Timer + static $LastNode = $null + static [void] Start() { [ScriptProfiler]::Queue = New-Object System.Collections.Queue @@ -15,5 +17,7 @@ class ScriptProfiler { Breakpoint = $InputObject Elapsed = [ScriptProfiler]::Timer.Elapsed }) + + [ScriptProfiler]::LastNode = $InputObject } }