microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cleanup/test-consolelogs

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

dotnet/agentLauncher/src/Show-Timing.ps1

48lines · modecode

1$ErrorActionPreference = "Stop"
2
3$logPath = Join-Path ([Environment]::GetFolderPath('LocalApplicationData')) 'AgentLauncher\agent.log'
4
5if (-not (Test-Path $logPath)) {
6 Write-Host "Log file not found at: $logPath" -ForegroundColor Red
7 exit 1
8}
9
10Write-Host "`nTiming Analysis - Latest Activation" -ForegroundColor Cyan
11Write-Host "====================================`n" -ForegroundColor Cyan
12
13# Get timing lines from the latest activation
14$timingLines = Get-Content $logPath | Where-Object { $_ -match 'TIMING' } | Select-Object -Last 20
15
16if ($timingLines.Count -eq 0) {
17 Write-Host "No timing data found in log" -ForegroundColor Yellow
18 exit 0
19}
20
21Write-Host "Detailed Timing Breakdown:" -ForegroundColor Green
22Write-Host ""
23
24$previousMs = 0
25foreach ($line in $timingLines) {
26 if ($line -match '\[TIMING \[([^\]]+)\]\] \+(\d+)ms - (.+)') {
27 $marker = $matches[1]
28 $totalMs = [int]$matches[2]
29 $description = $matches[3]
30 $delta = $totalMs - $previousMs
31
32 $color = "White"
33 if ($delta -gt 1000) { $color = "Red" }
34 elseif ($delta -gt 500) { $color = "Yellow" }
35 elseif ($delta -gt 100) { $color = "Cyan" }
36
37 Write-Host (" {0,-30} {1,6}ms (Δ{2,6}ms) {3}" -f $marker, $totalMs, $delta, $description) -ForegroundColor $color
38 $previousMs = $totalMs
39 }
40}
41
42Write-Host "`n" -ForegroundColor Cyan
43Write-Host "Total Time: ${previousMs}ms" -ForegroundColor Green
44Write-Host "`nColor Legend:" -ForegroundColor Gray
45Write-Host " Red = >1000ms (1+ seconds)" -ForegroundColor Red
46Write-Host " Yellow = >500ms" -ForegroundColor Yellow
47Write-Host " Cyan = >100ms" -ForegroundColor Cyan
48Write-Host " White = <100ms" -ForegroundColor White
49