Everything is stable again. Some refactoring work is still in progress !deploy

This commit is contained in:
KevinMarquette
2017-02-04 23:18:43 -08:00
parent af7e4143cc
commit 1b83630001
4 changed files with 35 additions and 16 deletions

View File

@@ -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()
{

View File

@@ -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"
}
}

View File

@@ -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

View File

@@ -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 {