|
| 1 | +# Analyze Benchmark Results |
| 2 | +# Run this AFTER you've run the benchmarks manually |
| 3 | + |
| 4 | +Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 5 | +Write-Host " SharpCoreDB Benchmark Results Analyzer" -ForegroundColor Cyan |
| 6 | +Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 7 | +Write-Host "" |
| 8 | + |
| 9 | +# Check if results exist |
| 10 | +if (-not (Test-Path "BenchmarkDotNet.Artifacts\results")) { |
| 11 | + Write-Host "? No results found!" -ForegroundColor Red |
| 12 | + Write-Host "" |
| 13 | + Write-Host "Please run benchmarks first:" -ForegroundColor Yellow |
| 14 | + Write-Host " 1. Start the benchmark app: dotnet run -c Release" -ForegroundColor White |
| 15 | + Write-Host " 2. Choose option 1 or 2" -ForegroundColor White |
| 16 | + Write-Host " 3. Wait for completion" -ForegroundColor White |
| 17 | + Write-Host " 4. Run this script again" -ForegroundColor White |
| 18 | + exit 1 |
| 19 | +} |
| 20 | + |
| 21 | +# Find most recent markdown files |
| 22 | +$mdFiles = Get-ChildItem -Path "BenchmarkDotNet.Artifacts\results" -Filter "*-report-github.md" -File | |
| 23 | + Sort-Object LastWriteTime -Descending |
| 24 | + |
| 25 | +if ($mdFiles.Count -eq 0) { |
| 26 | + Write-Host "? No markdown result files found!" -ForegroundColor Red |
| 27 | + exit 1 |
| 28 | +} |
| 29 | + |
| 30 | +Write-Host "Found $($mdFiles.Count) result file(s):" -ForegroundColor Green |
| 31 | +Write-Host "" |
| 32 | + |
| 33 | +# Show recent results |
| 34 | +foreach ($file in $mdFiles | Select-Object -First 5) { |
| 35 | + Write-Host "?? $($file.Name)" -ForegroundColor Cyan |
| 36 | + Write-Host " Last modified: $($file.LastWriteTime)" -ForegroundColor Gray |
| 37 | + Write-Host " Size: $([math]::Round($file.Length / 1KB, 2)) KB" -ForegroundColor Gray |
| 38 | + Write-Host "" |
| 39 | +} |
| 40 | + |
| 41 | +# Ask which to analyze |
| 42 | +Write-Host "Which benchmark do you want to analyze?" -ForegroundColor Yellow |
| 43 | +Write-Host "" |
| 44 | +Write-Host " 1) Most recent ($(($mdFiles | Select-Object -First 1).Name))" -ForegroundColor White |
| 45 | +Write-Host " 2) Show all recent results" -ForegroundColor White |
| 46 | +Write-Host " 3) Open results folder" -ForegroundColor White |
| 47 | +Write-Host "" |
| 48 | + |
| 49 | +$choice = Read-Host "Enter choice (1-3)" |
| 50 | + |
| 51 | +switch ($choice) { |
| 52 | + "1" { |
| 53 | + $latest = $mdFiles | Select-Object -First 1 |
| 54 | + Write-Host "" |
| 55 | + Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 56 | + Write-Host " Analysis: $($latest.Name)" -ForegroundColor Cyan |
| 57 | + Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 58 | + Write-Host "" |
| 59 | + |
| 60 | + # Read and display content |
| 61 | + $content = Get-Content $latest.FullName -Raw |
| 62 | + |
| 63 | + # Extract table |
| 64 | + $lines = $content -split "`n" |
| 65 | + $inTable = $false |
| 66 | + $tableLines = @() |
| 67 | + |
| 68 | + foreach ($line in $lines) { |
| 69 | + if ($line -match "^\| Method ") { |
| 70 | + $inTable = $true |
| 71 | + } |
| 72 | + |
| 73 | + if ($inTable) { |
| 74 | + $tableLines += $line |
| 75 | + |
| 76 | + if ($line -notmatch "^\|") { |
| 77 | + break |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + # Display table |
| 83 | + if ($tableLines.Count -gt 0) { |
| 84 | + Write-Host "?? BENCHMARK RESULTS:" -ForegroundColor Green |
| 85 | + Write-Host "" |
| 86 | + foreach ($line in $tableLines) { |
| 87 | + if ($line -match "Baseline") { |
| 88 | + Write-Host $line -ForegroundColor Yellow |
| 89 | + } |
| 90 | + elseif ($line -match "Optimized") { |
| 91 | + Write-Host $line -ForegroundColor Green |
| 92 | + } |
| 93 | + elseif ($line -match "SQLite") { |
| 94 | + Write-Host $line -ForegroundColor Cyan |
| 95 | + } |
| 96 | + else { |
| 97 | + Write-Host $line |
| 98 | + } |
| 99 | + } |
| 100 | + Write-Host "" |
| 101 | + } |
| 102 | + |
| 103 | + # Check for issues |
| 104 | + if ($content -match "Benchmarks with issues:") { |
| 105 | + Write-Host "?? WARNING: Some benchmarks had issues!" -ForegroundColor Red |
| 106 | + Write-Host "" |
| 107 | + |
| 108 | + $issuesStart = $content.IndexOf("Benchmarks with issues:") |
| 109 | + $issuesSection = $content.Substring($issuesStart).Split("`n") | Select-Object -First 20 |
| 110 | + |
| 111 | + foreach ($line in $issuesSection) { |
| 112 | + if ($line.Trim()) { |
| 113 | + Write-Host " $line" -ForegroundColor Yellow |
| 114 | + } |
| 115 | + } |
| 116 | + Write-Host "" |
| 117 | + } |
| 118 | + else { |
| 119 | + Write-Host "? All benchmarks completed successfully!" -ForegroundColor Green |
| 120 | + Write-Host "" |
| 121 | + } |
| 122 | + |
| 123 | + # Offer to open HTML report |
| 124 | + $htmlFile = $latest.FullName -replace "-github\.md$", ".html" |
| 125 | + if (Test-Path $htmlFile) { |
| 126 | + $openHtml = Read-Host "Open interactive HTML report? (Y/N)" |
| 127 | + if ($openHtml -eq "Y" -or $openHtml -eq "y") { |
| 128 | + Start-Process $htmlFile |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + "2" { |
| 134 | + Write-Host "" |
| 135 | + Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 136 | + Write-Host " All Recent Results" -ForegroundColor Cyan |
| 137 | + Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 138 | + Write-Host "" |
| 139 | + |
| 140 | + foreach ($file in $mdFiles | Select-Object -First 10) { |
| 141 | + Write-Host "?? $($file.Name)" -ForegroundColor Cyan |
| 142 | + Write-Host " Modified: $($file.LastWriteTime)" -ForegroundColor Gray |
| 143 | + Write-Host " Path: $($file.FullName)" -ForegroundColor DarkGray |
| 144 | + Write-Host "" |
| 145 | + } |
| 146 | + } |
| 147 | + |
| 148 | + "3" { |
| 149 | + Write-Host "" |
| 150 | + Write-Host "Opening results folder..." -ForegroundColor Cyan |
| 151 | + Start-Process "BenchmarkDotNet.Artifacts\results" |
| 152 | + } |
| 153 | + |
| 154 | + default { |
| 155 | + Write-Host "" |
| 156 | + Write-Host "Invalid choice" -ForegroundColor Red |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | +Write-Host "" |
| 161 | +Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 162 | +Write-Host " Analysis Complete" -ForegroundColor Cyan |
| 163 | +Write-Host "???????????????????????????????????????????????????????" -ForegroundColor Cyan |
| 164 | +Write-Host "" |
| 165 | + |
| 166 | +# Offer to save analysis to file |
| 167 | +$saveAnalysis = Read-Host "Save analysis to file? (Y/N)" |
| 168 | +if ($saveAnalysis -eq "Y" -or $saveAnalysis -eq "y") { |
| 169 | + $outputFile = "benchmark_analysis_$(Get-Date -Format 'yyyy-MM-dd_HH-mm-ss').txt" |
| 170 | + |
| 171 | + $latest = $mdFiles | Select-Object -First 1 |
| 172 | + $content = Get-Content $latest.FullName -Raw |
| 173 | + |
| 174 | + $analysis = @" |
| 175 | +??????????????????????????????????????????????????????? |
| 176 | + SharpCoreDB Benchmark Analysis |
| 177 | + Generated: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') |
| 178 | +??????????????????????????????????????????????????????? |
| 179 | +
|
| 180 | +Source File: $($latest.Name) |
| 181 | +Last Modified: $($latest.LastWriteTime) |
| 182 | +
|
| 183 | +$content |
| 184 | +"@ |
| 185 | + |
| 186 | + $analysis | Out-File -FilePath $outputFile -Encoding UTF8 |
| 187 | + Write-Host "" |
| 188 | + Write-Host "? Analysis saved to: $outputFile" -ForegroundColor Green |
| 189 | + Write-Host "" |
| 190 | +} |
0 commit comments