Skip to content

Commit

Permalink
refactor perf creation into common.ps1 (#788)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfriesen authored Jan 13, 2025
1 parent eeaedb8 commit 6b96c83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
30 changes: 30 additions & 0 deletions tools/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,36 @@ function Initiate-Bugcheck {
& $NotMyFault -accepteula -bugcheck $Code
}

function New-PerfDataSet {
param (
[Parameter()]
[string[]]$Files = @()
)

$Results = [System.Collections.ArrayList]::new()

foreach ($File in $Files) {
if (-not [string]::IsNullOrEmpty($File) -and (Test-Path $File)) {
$Results.AddRange($(Get-Content -Raw $File | ConvertFrom-Json))
}
}

return Write-Output -NoEnumerate $Results
}

function Write-PerfDataSet {
param (
[Parameter()]
[object]$DataSet,

[Parameter()]
[string]$File
)

New-Item -ItemType Directory -Force -Path (Split-Path $File) | Out-Null
$DataSet | ConvertTo-Json -Depth 100 | Out-File -FilePath $File -Encoding utf8
}

function New-PerfData {
param (
[Parameter()]
Expand Down
8 changes: 2 additions & 6 deletions tools/xskperfsuite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,7 @@ try {
}

try {
$Results = [System.Collections.ArrayList]::new()

if (-not [string]::IsNullOrEmpty($RawResultsFile) -and (Test-Path $RawResultsFile)) {
$Results.AddRange($(Get-Content -Raw $RawResultsFile | ConvertFrom-Json))
}
$Results = New-PerfDataSet -Files $RawResultsFile

for ($i = 0; $i -lt $Iterations; $i++) {
$TmpFile = [System.IO.Path]::GetTempFileName()
Expand Down Expand Up @@ -246,7 +242,7 @@ try {
Write-Host $($Format -f $ScenarioName, [Math]::ceiling($avg), [Math]::ceiling($stddev))

if (-not [string]::IsNullOrEmpty($RawResultsFile)) {
Set-Content -Path $RawResultsFile -Value $($Results | ConvertTo-Json -Depth 100)
Write-PerfDataSet -DataSet $Results -File $RawResultsFile
}
} catch {
Write-Error "$($PSItem.Exception.Message)`n$($PSItem.ScriptStackTrace)"
Expand Down

0 comments on commit 6b96c83

Please sign in to comment.