-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiskspdtest.ps1
More file actions
60 lines (48 loc) · 2.19 KB
/
diskspdtest.ps1
File metadata and controls
60 lines (48 loc) · 2.19 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
### Warning: This script is for educational purposes only. Use at your own risk.
### It is recommended to not do benchmarks on production systems.
### This script will run diskspd on all non-C: fixed drives for the given number of iterations each.
### It will create a file named "iotest.dat" on each drive and save the results in the output directory.
### Make sure to adjust the parameters as needed.
param(
[string]$DiskspdPath = "diskspd.exe",
[string]$OutputDirectory = "$PSScriptRoot\results",
[int]$Iterations = 5
)
# Define variables
$parameters = "-b8K -d60 -o4 -t32 -h -r -w25 -L -Z1G -c200G"
# Dynamically discover all non-C: fixed disk volumes
$drives = Get-Volume | Where-Object {
$_.DriveType -eq 'Fixed' -and
$_.DriveLetter -and
$_.DriveLetter -ne 'C'
} | Select-Object -ExpandProperty DriveLetter | Sort-Object
if ($drives.Count -eq 0) {
Write-Host "No non-C: fixed drives detected. Exiting." -ForegroundColor Red
exit 1
}
Write-Host "Detected non-C: fixed drives: $($drives -join ', ')" -ForegroundColor Cyan
# Ensure the output directory exists
if (!(Test-Path -Path $OutputDirectory)) {
New-Item -ItemType Directory -Path $OutputDirectory | Out-Null
}
# Loop through each drive
foreach ($drive in $drives) {
# Create a per-drive subdirectory for results
$driveOutputDir = Join-Path $OutputDirectory $drive
if (!(Test-Path -Path $driveOutputDir)) {
New-Item -ItemType Directory -Path $driveOutputDir | Out-Null
}
for ($i = 1; $i -le $Iterations; $i++) {
# Generate timestamp
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
# Construct the output file name
$outputFile = "$driveOutputDir\DiskSpeedResults_${drive}_Seq${i}_${timestamp}.txt"
# Construct the command
$filePath = "${drive}:\iotest.dat"
$command = "& `"$DiskspdPath`" $parameters $filePath"
# Run the command and save output to the new file
Write-Output "Running diskspd on drive $drive (Iteration $i of $Iterations)..."
Invoke-Expression "$command | Out-File -FilePath $outputFile -Encoding UTF8"
}
}
Write-Host "`nAll benchmarks complete. Results saved to: $OutputDirectory" -ForegroundColor Green