reworked some files skip ci

This commit is contained in:
KevinMarquette
2017-02-05 00:00:58 -08:00
parent 1b83630001
commit baa544d924
4 changed files with 58 additions and 42 deletions

View File

@@ -46,45 +46,3 @@ class Chronometer
}
}
class MonitoredScript
{
[string]$Path
[System.Collections.ArrayList]$Line
hidden $lastNode = $null
hidden $lastRecord = $null
MonitoredScript()
{
$this.Line = [System.Collections.ArrayList]::New()
}
[int] SetScript([string]$Path)
{
Get-Content -Path $Path | %{ $this.Line.Add( [ScriptLine]@{text=$_})}
return $this.Line.Count
}
[void] AddExecution([hashtable]$node)
{
$record = $this.Line[$node.Breakpoint.Line-1]
$record.LineNumber = $node.Breakpoint.Line - 1
if($this.lastNode)
{
$duration = $node.ElapsedMilliseconds - $this.lastNode.ElapsedMilliseconds
}
else
{
$duration = $node.ElapsedMilliseconds
}
if($this.lastRecord)
{
$this.lastRecord.AddExecutionTime($duration)
}
$this.lastRecord = $record
$this.lastNode = $node
}
}

View File

@@ -0,0 +1,49 @@
class MonitoredScript
{
[string]$Path
[System.Collections.Generic.List[ScriptLine]]$Line
hidden $lastNode = $null
hidden $lastRecord = $null
[float]$ExecutionTime = 0
[int]$LinesOfCode = 0
MonitoredScript()
{
$this.Line =New-Object 'System.Collections.Generic.List[ScriptLine]'
}
[int] SetScript([string]$Path)
{
Get-Content -Path $Path | %{ $this.Line.Add( [ScriptLine]@{text=$_;path=$path})}
$this.LinesOfCode = $this.Line.Count
return $this.LinesOfCode
}
[void] AddExecution([hashtable]$node)
{
# Line numbers start at 1 but the array starts at 0
$lineNumber = $node.Breakpoint.Line - 1
$record = $this.Line[$lineNumber]
$record.LineNumber = $lineNumber
if($this.lastNode)
{
$duration = $node.ElapsedMilliseconds - $this.lastNode.ElapsedMilliseconds
}
else
{
$duration = $node.ElapsedMilliseconds
}
if($this.lastRecord)
{
$this.lastRecord.AddExecutionTime($duration)
$this.ExecutionTime += $duration
}
$this.lastRecord = $record
$this.lastNode = $node
}
}

View File

@@ -7,6 +7,7 @@ Write-Verbose 'Import Classes in order because of dependencies'
$classList = @(
'ScriptLine',
'ScriptProfiler',
'MonitoredScript',
'Chronometer'
)

View File

@@ -42,5 +42,13 @@ Describe "Basic unit tests" -Tags Build {
{[ScriptProfiler]::Start()} | Should Not Throw
}
}
Context "Class: MonitoredScript" {
{[MonitoredScript]::New()} | Should Not Throw
}
Context "Class: MonitoredScript" {
{[MonitoredScript]::SetScript("$projectRoot\scratchfiles\example.ps1")} | Should Not Throw
}
}
}