Add-PerformanceRecord.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<#
 
.SYNOPSIS
 
.DESCRIPTION
 
.PARAMETER
 
.INPUTS
 
.OUTPUTS
 
.EXAMPLE
 
#>


function Add-PerformanceRecord {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        $Name,
        [Parameter(Mandatory = $true, Position = 1)]
        [datetime] $Time
    )

    if (!$script:PerformanceRecord.ContainsKey($Name)) {
        $script:PerformanceRecord.Add($Name, (Get-Date) - $Time)
    } else {
        $script:PerformanceRecord[$Name] += (Get-Date) - $Time
    }
}