Commit 06b4df0c authored by Dustin L. Howett's avatar Dustin L. Howett

Time how long profile components take to run; add Get-ProfileTimings

parent 053e4247
ForEach($i In (Get-ChildItem (Join-Path (Split-Path $Profile.CurrentUserAllHosts) profile.d) -Filter:*.ps1 -EA:Ignore)) {
$Script:DH_PROFILE_VARS = @{
ProfileTimings = @();
};
ForEach($i In (Get-ChildItem (Join-Path (Split-Path $Profile.CurrentUserAllHosts) profile.d) -Filter:*.ps1 -EA:Ignore)) {
$start = Get-Date
. ($i.FullName)
$end = Get-Date
$Script:DH_PROFILE_VARS.ProfileTimings += @{
Name = $i.Name;
Duration = $end.Subtract($start);
}
}
Function Get-ProfileTimings {
$total = 0
ForEach($v in $Script:DH_PROFILE_VARS.ProfileTimings) {
$ms=$v.Duration.TotalMilliseconds
$color=[ConsoleColor]::Green
if ($ms -gt 100) {
$color=[ConsoleColor]::Yellow
}
if ($ms -gt 1000) {
$color=[ConsoleColor]::Red
}
Write-Host -Fore $color ("{0,-10:F04}ms" -f $ms) -nonewline
Write-Host -Fore Cyan " | " -nonewline
Write-Host -Fore White $v.Name
$total+=$ms
}
Write-Host -Fore Cyan "-------------+"
Write-Host -Fore White ("{0,-10:F04}ms" -f $total) -NoNewLine
Write-Host -Fore Cyan " | " -NoNewLine
Write-Host -Fore White ("{0} entries" -f $Script:DH_PROFILE_VARS.ProfileTimings.Length)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment