Everything is stable again. Some refactoring work is still in progress !deploy
This commit is contained in:
@@ -35,9 +35,15 @@ class Chronometer
|
||||
$script = $Execution.Breakpoint.Script
|
||||
if($this.FileMap.ContainsKey($script))
|
||||
{
|
||||
# Each script tracks it's own execution times
|
||||
$this.FileMap[$script].AddExecution($Execution)
|
||||
}
|
||||
}
|
||||
|
||||
[MonitoredScript[]] GetResults()
|
||||
{
|
||||
return $this.FileMap.Values
|
||||
}
|
||||
}
|
||||
|
||||
class MonitoredScript
|
||||
@@ -45,8 +51,8 @@ class MonitoredScript
|
||||
[string]$Path
|
||||
[System.Collections.ArrayList]$Line
|
||||
|
||||
$lastNode = $null
|
||||
$lastRecord = $null
|
||||
hidden $lastNode = $null
|
||||
hidden $lastRecord = $null
|
||||
|
||||
MonitoredScript()
|
||||
{
|
||||
|
||||
@@ -22,23 +22,29 @@ function Get-Chronometer
|
||||
)
|
||||
|
||||
$Chronometer = [Chronometer]::New()
|
||||
$breakPoint = $Chronometer.AddBreakpoint($Path)
|
||||
|
||||
Write-Verbose "Setting breapoints"
|
||||
$Chronometer.AddBreakpoint($Path)
|
||||
|
||||
if($Chronometer.breakPoint -ne $null)
|
||||
{
|
||||
Write-Verbose "Executing Script"
|
||||
[ScriptProfiler]::Start()
|
||||
[void] $ScriptBlock.Invoke()
|
||||
|
||||
Write-Verbose "Clearing Breapoints"
|
||||
$Chronometer.ClearBreakpoint()
|
||||
|
||||
Write-Verbose "Processing data"
|
||||
foreach($node in [ScriptProfiler]::Queue.GetEnumerator())
|
||||
{
|
||||
$Chronometer.AddExecution($node)
|
||||
}
|
||||
|
||||
foreach($script in $fileMap.Keys)
|
||||
{
|
||||
foreach($line in $fileMap[$script])
|
||||
{
|
||||
Write-Output $line
|
||||
Write-Output $Chronometer.GetResults()
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Warning "Parsing files did not result in any breakpoints"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ Provide a script file and a command to execute.
|
||||
|
||||
$path = myscript.ps1
|
||||
Get-Chronometer -Path $path -Script {. .\myscript.ps1} -OutVariable report
|
||||
$report.ToString()
|
||||
$report.line | % tostring
|
||||
|
||||
The user experience is important to me but I am working on the core logic right now. I will loop back to make it more intuitive and simple to use.
|
||||
|
||||
## Things to know
|
||||
|
||||
@@ -11,6 +11,12 @@ Describe "Basic unit tests" -Tags Build {
|
||||
# Get-Chronometer -Path ScratchFiles\example.ps1 -Script {"Test"}
|
||||
{Get-Chronometer -Path $PSScriptRoot\..\ScratchFiles\example.ps1 -Script {"Test"} } | Should Not Throw
|
||||
}
|
||||
|
||||
it "Executes a script and gives results" {
|
||||
# Get-Chronometer -Path ScratchFiles\example.ps1 -Script {"Test"}
|
||||
$results = Get-Chronometer -Path $PSScriptRoot\..\ScratchFiles\example.ps1 -Script {. "$PSScriptRoot\..\ScratchFiles\example.ps1"}
|
||||
$results | Should Not BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
InModuleScope $moduleName {
|
||||
|
||||
Reference in New Issue
Block a user