-
Notifications
You must be signed in to change notification settings - Fork 52
/
ezfio.ps1
1374 lines (1230 loc) · 61.6 KB
/
ezfio.ps1
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ezfio 1.0
#
# ------------------------------------------------------------------------
# ezfio is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# ezfio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ezfio. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------
#
# Usage: ezfio.ps1 -drive {physicaldrive number}
# Example: ezfio.ps1 -drive 3
#
# When no parameters are specified, the script will provide usage info
# as well as a list of attached PhysicalDrives
#
# This script requires Administrator privileges so must be run from
# a PowerShell session started with "Run as Administrator."
#
# If Windows errors with, "...cannot be loaded because running scripts is
# disabled on this system...." you need to run the following line to enable
# execution of local PowerShell scripts:
# Set-ExecutionPolicy -scope CurrentUser RemoteSigned
#
# Please be sure to have FIO installed, or you will be prompted to install
# and re-run the script.
param (
[string]$drive = "none",
[string]$outDir = "none",
[int]$util = 100,
[switch]$help,
[switch]$yes,
[switch]$nullio,
[switch]$fastprecond,
[switch]$quickie
)
Add-Type -Assembly System.IO.Compression
Add-Type -Assembly System.IO.Compression.FileSystem
Add-Type -AssemblyName PresentationFramework, System.Windows.Forms
Add-Type -AssemblyName PresentationCore
Chdir (Split-Path $script:MyInvocation.MyCommand.Path)
function WindowFromXAML( $xaml, $prefix )
{
# Create a WPF window from XAML from DevStudio
$xaml = $xaml -replace 'mc:Ignorable="d"', ''
$xaml = $xaml -replace "x:N", 'N'
$xaml = $xaml -replace '^<Win.*', '<Window'
$xml = [xml]$xaml
$reader = (New-Object System.Xml.XmlNodeReader $xml)
try{ $window = [Windows.Markup.XamlReader]::Load( $reader ) }
catch { Write-Host "Unable to load XAML for window."; return $null; }
# Set the variables locally in the calling function. Please forgive me.
$xml.SelectNodes("//*[@Name]") |
%{Set-Variable -Name "$($prefix)_$($_.Name)" -Value $window.FindName($_.Name) -Scope 1}
return $window
}
function CheckAdmin()
{
# Check that we have root privileges for disk access, abort if not.
if ( -not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") ) {
[System.Windows.Forms.MessageBox]::Show( "Administrator privileges are required for low-level disk access.`nPlease restart this script as Administrator to continue.", "Fatal Error", 0, 48 ) | Out-Null
exit
}
}
function FindFIO()
{
# Try the path to the FIO executable, return path or exit.
if ( -not (Get-Command fio.exe) ) {
$ret = [System.Windows.Forms.MessageBox]::Show( "FIO is required to run IO tests. Would you like to install?", "FIO Not Detected", 4, 32 )
if ($ret -eq "yes" ) {
Start-Process "https://www.bluestop.org/fio/"
}
exit
} else {
$global:fio = (Get-Command fio.exe).Path
}
}
function CheckFIOVersion()
{
# Check we have a version of FIO we can use.
try {
$global:fioVerString = ( . $global:fio "--version" )
$fiov = ( . $global:fio "--version" ).Split('-')[1].Split('.')[0]
if ([int]$fiov -lt 2) {
$err = "ERROR! FIO version " + (. $global:fio "--version") + " is unsupported. Version 2.0 or later is required"
if ($global:testmode -eq "gui") {
[System.Windows.Forms.MessageBox]::Show( $err, "Fatal Error", 0, 48 ) | Out-Null
} else {
Write-Error $err
}
exit 1
}
} catch {
$err = "ERROR! Unable to determine FIO version. Version 2.0 or later is required."
if ($global:testmode -eq "gui") {
[System.Windows.Forms.MessageBox]::Show( $err, "Fatal Error", 0, 48 ) | Out-Null
} else {
Write-Error $err
}
exit 1
}
try {
$out = (. $global:fio "--parse-only" "--output-format=json+")
if ($LastExitCode -eq 0 ) {
$global:fioOutputFormat = "json+"
}
} catch {
# Nothing, we can't make exceedance
}
}
function ParseArgs()
{
# Set the global values to the param() values, so that Parse() can see them
function IntroDialog()
{
# Gets user test parameters if not specified on the command line
$xaml = @'
<Window x:Class="Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ezFIO Drive Selection" ResizeMode="NoResize" Height="281" Width="456">
<Grid>
<Label Content="Drive to test:" HorizontalAlignment="Left" Margin="24,16,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="driveList" HorizontalAlignment="Left" Margin="115,20,0,0" VerticalAlignment="Top" Width="218"/>
<Button x:Name="startTest" Content="Start Test" HorizontalAlignment="Left" Margin="358,79,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:Name="exit" Content="Exit" HorizontalAlignment="Left" Margin="358,125,0,0" VerticalAlignment="Top" Width="75"/>
<GroupBox Header="Information" HorizontalAlignment="Left" Margin="24,55,0,0" VerticalAlignment="Top" Height="109" Width="309">
<Grid>
<Label Content="Model:" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,0,0,0"/>
<Label x:Name="modelName" Content="Happy NVME" HorizontalAlignment="Left" Margin="50,0,0,0" VerticalAlignment="Top"/>
<Label Content="Serial:" HorizontalAlignment="Left" Margin="8,25,0,0" VerticalAlignment="Top"/>
<Label x:Name="serial" Content="NVME001" HorizontalAlignment="Left" Margin="50,25,0,0" VerticalAlignment="Top"/>
<Label Content="Size:" HorizontalAlignment="Left" Margin="15,50,0,0" VerticalAlignment="Top"/>
<Label x:Name="sizeGB" Content="100GB" HorizontalAlignment="Left" Margin="50,50,0,0" VerticalAlignment="Top"/>
</Grid>
</GroupBox>
<GroupBox Header="WARNING! WARNING! WARNING!" HorizontalAlignment="Left" Margin="24,176,0,0" VerticalAlignment="Top" Width="398">
<Label >
<TextBlock TextWrapping="WrapWithOverflow" Width="376" HorizontalAlignment="Center" VerticalAlignment="Center">All data on the selected drive will be destroyed by the test. Please make sure there are no mounted filesystems or data on the drive.</TextBlock>
</Label>
</GroupBox>
</Grid>
</Window>
'@
$intro = WindowFromXAML $xaml 'intro'
$intro.Icon = $global:iconBitmap
$pd = @{}
$intro.add_Loaded( {
$intro.Activate()
$intro_driveList.Focus()
$global:physDrive = $null
# Populate the physicaldrive list
$drives = Get-WmiObject -query "SELECT * from Win32_DiskDrive" | Sort-Object
foreach ( $drive in $drives ) {
$idx = $intro_driveList.Items.Add( $drive.DeviceID )
$pd.Add( $idx, $drive )
}
$intro_driveList.SelectedIndex = 0
$drive = $pd.Get_Item( 0 )
$intro_modelName.Content = $drive.Model.Trim()
if ($drive.SerialNumber -ne $null) { $intro_serial.Content = $drive.SerialNumber.Trim() }
else { $intro_serial.Content = "UNKNOWN" }
$intro_sizeGB.Content = [string]::Format( "{0} GB", [int]($drive.Size/1000000000) )
$intro_driveList.add_SelectionChanged( {
$idx = $intro_driveList.SelectedIndex
$drive = $pd.Get_Item( $idx )
$intro_modelName.Content = $drive.Model.Trim()
if ($drive.SerialNumber -ne $null) { $intro_serial.Content = $drive.SerialNumber.Trim() }
else { $intro_serial.Content = "UNKNOWN" }
$intro_sizeGB.Content = [string]::Format( "{0} GB", [int]($drive.Size/1000000000) )
} )
$intro_startTest.add_Click( {
$idx = $intro_driveList.SelectedIndex
$drive = $pd.Get_Item( $idx )
$global:physDrive = $drive.DeviceID
$intro.dialogResult = $true
$intro.Close()
} )
$intro_exit.add_Click( { $intro.Close() } )
} )
$intro.ShowDialog()
}
# Parse command line options into globals.
function usage()
{
# How to use the script, and some handy info on current drives
$scriptname = split-path $global:scriptName -Leaf
"ezfio, an in-depth IO tester for NVME devices"
"WARNING: All data on any tested device will be destroyed!`n"
"Usage: "
[string]::Format(" .\{0} -drive <PhysicalDiskNumber> [-util <1..100>] [-outDir <path>] [-nullIO]", $scriptname)
[string]::Format("EX: .\{0} -drive 2 -util 100`n", $scriptname)
"PhysDrive is the ID number of the \\PhysicalDrive to test"
"Usage is the percent of total size to test (100%=default)`n"
"`nPhysical disks:"
$drives=Get-WmiObject -query "SELECT * from Win32_DiskDrive" | Sort-Object
foreach ( $drive in $drives ) {
if ($drive.SerialNumber -ne $null) {
[string]::Format( "{0}. {1}, Serial: {2}, Size: {3}GB",
$drive.DeviceID.substring(17), $drive.Model.Trim(),
$drive.SerialNumber.Trim(), [int]($drive.Size/1000000000) )
} else {
[string]::Format( "{0}. {1}, Size: {2}GB",
$drive.DeviceID.substring(17), $drive.Model.Trim(),
[int]($drive.Size/1000000000) )
}
}
exit
}
if ($help) { usage }
if (($util -lt 1) -or ($util -gt 100)) {
"ERROR: Utilization must be between 1 and 100.`n"
usage
} else {
$global:utilization = $util
}
if ( $outDir -eq "none" ) {
$global:outDir = "${PWD}"
} else {
$global:outDir = "$outDir"
}
if ( $drive -ne "none" ) {
$global:testMode = "cli"
if ( $drive -notin (Get-Disk).Number ){
Write-Error "The drive number `"$drive`" you entered does not exist.`n`n"
usage
}
$global:physDrive = "\\.\PhysicalDrive$drive"
} else {
$global:testmode = "gui"
$ok = IntroDialog
if (-not ($ok) ) {
exit
}
}
$global:yes = $yes
if ( -not $nullio ) {
$global:ioengine = "windowsaio"
} else {
$global:ioengine = "null"
}
$global:quickie = $quickie
$global:fastPrecond = $fastprecond
# Do a sanity check that the selected drive does not show as a local drive letter
Get-WMIObject Win32_LogicalDisk | Foreach-Object {
$did = (Get-WmiObject -Query "Associators of {Win32_LogicalDisk.DeviceID='$($_.DeviceID)'} WHERE ResultRole=Antecedent").Path
$dl = $_.DeviceID
if ($did.RelativePath) {
$part = $did.RelativePath.Split('"')[1]
$pd = $part.split(',')[0].split('#')[1]
if ($global:physDrive.ToLower() -eq "\\.\physicaldrive$pd") {
if ($global:testmode -eq "cli") {
Write-Error "ERROR! Drive '$global:physdrive' is mounted as drive '$dl'!"
Write-Error "Aborting run, cannot run on mounted filesystem."
exit
} else {
[System.Windows.Forms.MessageBox]::Show( "ERROR! Drive '$global:physdrive' is mounted as drive '$dl'!`nAborting run, cannot run on mounted filesystem.", "Fatal Error", 0, 48 ) | Out-Null
exit
}
}
}
}
}
function CollectSystemInfo()
{
# Collect some OS and CPU information.
# May want to put a window up while this happens. GWMI is very slow
$procs = [array](Get-WmiObject -class win32_processor) # Single-socket gives object, so coerce into array to match multisocket
$global:cpu = $procs[0].Name.Trim()
$cpuCount = ($procs[0].NumberOfCores).Count
$cpuCores = ($procs[0] | Where DeviceID -eq "CPU0" ).NumberOfLogicalProcessors
$global:cpuCores = $cpuCores * $cpuCount
$global:cpuFreqMHz = ($procs[0] | Where DeviceID -eq "CPU0").MaxClockSpeed
$os = Get-WmiObject Win32_OperatingSystem
$global:uname = $os.Caption.Trim() + " - Build " + $os.BuildNumber.Trim() + " - ServicePack " + $os.ServicePackMajorVersion + "." + $os.ServicePackMinorVersion
# Check if we're running in high-performance mode
$plan = Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "IsActive=True"
if (-not ($plan.InstanceID -like "*8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c*")) {
function SetHighPerformance() {
"Setting High Performance power scheme via POWERCFG"
powercfg /setactive "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
}
if ($global:yes) {
SetHighPerformance
} elseif ($testmode -ne "gui") {
"-" * 75
"Power mode is not currently set to High Performance."
"This may result in lowered test results."
$cont = Read-Host "Would you like to enable this power setting now? (y/n)"
"-" * 75
if ($cont -ne "") {
if ($cont.Substring(0, 1).ToLower() -eq "y" ) {
SetHighPerformance
}
}
} else {
$ret = [System.Windows.Forms.MessageBox]::Show(
"System power mode not set to High Performance.`nThis may result in lowered test results.`nWould you like to enable High Performance Mode now?",
"Verify Performance Mode", 4, 32)
if ($ret -eq"yes" ) {
SetHighPerformance
}
}
}
}
function VerifyContinue()
{
# User's last chance to abort the test. Exit if they don't agree.
if ( -not $global:yes ) {
if ($testMode -ne "gui") { # text-mode prompt since we're running with command line options
"-" * 75
"WARNING! " * 9
"THIS TEST WILL DESTROY ANY DATA AND FILESYSTEMS ON $global:physDrive"
$cont = Read-Host "Please type the word `"yes`" and hit return to continue, or anything else to abort"
"-" * 75
if ( $cont -ne "yes" ) {
"Performance test aborted, drive is untouched."
exit
}
} else {
# Do it in a messagebox since we're running GUI-wise
$ret = [System.Windows.Forms.MessageBox]::Show(
"Test selected to run on $global:physDrive.`nALL DATA WILL BE ERASED ON THIS DRIVE`nContinue with testing?",
"Verify the device to test", 4)
if ($ret -ne "yes" ) {
"Performance test aborted, drive is untouched."
exit
}
}
}
}
function CollectDriveInfo()
{
# Get important device information, exit if not possible.
# We absolutely need this information
$global:physDriveBase = ([io.fileinfo]$global:physDrive).BaseName
$global:physDriveNo = $global:physDrive.Substring(17)
$global:physDriveBytes=(GET-WMIOBJECT win32_diskdrive | where DeviceID -eq $global:physDrive).Size
$global:physDriveGB=[long]($global:physDriveBytes/(1000*1000*1000))
$global:physDriveGiB=[long]($global:physDriveBytes/(1024*1024*1024))
$global:testcapacity = [long](($global:physDriveGiB * $global:utilization) / 100)
# This is just nice to have
$drive = (Get-Disk | Where-Object { $_.Number -eq $global:physDriveNo })
$global:model = $drive.Model.ToString().Trim()
if ($drive.SerialNumber -ne $null ) { $global:serial = $drive.SerialNumber.ToString().Trim() }
else { $global:serial = "UNKNOWN" }
}
# Set up names for all output/input files, place headers on CSVs.
function CSVInfoHeader {
if ($global:fastPrecond -eq $false) { $prefix = "" }
else { $prefix = "FASTPRECOND-" }
#Headers to the CSV file (ending up in the ODS at the test end)
"Drive,$prefix$global:physDrive"
"Model,$prefix$global:model"
"Serial,$prefix$global:serial"
"AvailCapacity,$prefix$global:physDriveGiB,GiB"
"TestedCapacity,$prefix$global:testcapacity,GiB"
"CPU,$prefix$global:cpu"
"Cores,$prefix$global:cpuCores"
"Frequency,$prefix$global:cpuFreqMHz"
"OS,$prefix$global:uname"
"FIOVersion,$prefix$global:fioVerString"
}
function SetupFiles()
{
# Datestamp for run output files
$global:ds=(Get-Date).ToString("yyyy-MM-dd_HH-mm-ss")
# The unique suffix we generate for all output files
$suffix="${global:physDriveGB}GB_${global:cpuCores}cores_${global:cpuFreqMHz}MHz_${global:physDriveBase}_${env:computername}_${global:ds}"
# Need to worry about normalizing passed in directory names, or else non-absolute output paths will resolve to c:\windows\system32\...
if ( -not ( Test-Path -Path $global:outDir ) ) {
# New-Item used PWD, so we're OK here
New-Item -ItemType directory -Path $global:outDir | Out-Null
}
# Now resolve to c:\... path and put back to global for sanity.
$global:outDir = Resolve-Path $global:outDir
# The "details" directory contains the raw output of each FIO run
$global:details = "${global:outDir}\details_${suffix}"
# The "details" directory contains the raw output of each FIO run
if ( Test-Path -Path $global:details ) {
Remove-Item -Recurse -Force $global:details | Out-Null
}
New-Item -ItemType directory -Path $global:details | Out-Null
# Copy this script into it for posterity
Copy-Item $scriptName $global:details
# Files we're going to generate, encode some system info in the names
# If the output files already exist, erase them
$global:testcsv = "${global:details}\ezfio_tests_${suffix}.csv"
if (Test-Path $global:testcsv) { Remove-Item $global:testcsv }
CSVInfoHeader > $global:testcsv
"Type,Write %,Block Size,Threads,Queue Depth/Thread,IOPS,Bandwidth (MB/s),Read Latency (us),Write Latency (us)" >> $global:testcsv
$global:timeseriescsv ="${global:details}\ezfio_timeseries_${suffix}.csv"
$global:timeseriesclatcsv ="${global:details}\ezfio_timeseriesclat_${suffix}.csv"
$global:timeseriesslatcsv ="${global:details}\ezfio_timeseriesslat_${suffix}.csv"
if (Test-Path $global:timeseriescsv) { Remove-Item $global:timeseriescsv }
if (Test-Path $global:timeseriesclatcsv) { Remove-Item $global:timeseriesclatcsv }
if (Test-Path $global:timeseriesslatcsv) { Remove-Item $global:timeseriesslatcsv }
CSVInfoHeader > $global:timeseriescsv
CSVInfoHeader > $global:timeseriesclatcsv
CSVInfoHeader > $global:timeseriesslatcsv
"IOPS" >> $global:timeseriescsv # Add IOPS header
"CLAT-read,CLAT-write" >> $global:timeseriesclatcsv
"SLAT-read,SLAT-write" >> $global:timeseriesslatcsv
# ODS input and output files
$global:odssrc = "${PWD}\original.ods"
$global:odsdest = "${global:outDir}\ezfio_results_${suffix}.ods"
if (Test-Path $global:odsdest) { Remove-Item $global:odsdest }
}
function TestName ($seqrand, $wmix, $bs, $threads, $iodepth)
{
# Return full path and filename prefix for test of specified params
$testfile = $global:details + "\Test" + $seqrand + "_w" + [string]$wmix
$testfile += "_bs" + [string]$bs + "_threads" + [string]$threads + "_iodepth"
$testfile += [string]$iodepth + "_" + $global:physDriveBase + ".out"
return $testfile
}
# The actual functions that run FIO, in a string so that we can do a Start-Job using it.
$global:jobutils = @'
function TestName ($seqrand, $wmix, $bs, $threads, $iodepth)
{
# Return full path and filename prefix for test of specified params
$testfile = $details + "\Test" + $seqrand + "_w" + [string]$wmix
$testfile += "_bs" + [string]$bs + "_threads" + [string]$threads + "_iodepth"
$testfile += [string]$iodepth + "_" + $physDriveBase + ".out"
return $testfile
}
function SequentialConditioning
{
# Sequentially fill the complete capacity of the drive once.
# Note that we can't use regular test runner because this test needs
# to run for a specified # of bytes, not a specified # of seconds.
if ( $quickie ) {
$size = "1G"
} else {
$size = "${testcapacity}G"
}
. $fio "--name=SeqCond" "--readwrite=write" "--bs=128k" "--ioengine=$ioengine" "--iodepth=64" "--direct=1" "--filename=$physDrive" "--size=$size" "--thread" | Out-Null
if ( $LastExitCode -ne 0 ) {
Write-Output "ERROR" "ERROR" "ERROR"
} else {
Write-Output "DONE" "DONE" "DONE"
}
}
function RandomConditioning
{
# Randomly write entire device for the full capacity
# Note that we can't use regular test runner because this test needs
# to run for a specified # of bytes, not a specified # of seconds.
if ( $quickie ) {
$size = "1G"
} else {
$size = "${testcapacity}G"
}
. $fio "--name=RandCond" "--readwrite=randwrite" "--bs=4k" "--invalidate=1" "--end_fsync=0" "--group_reporting" "--direct=1" "--filename=$physDrive" "--size=$size" "--ioengine=$ioengine" "--iodepth=256" "--norandommap" "--randrepeat=0" "--thread" | Out-Null
if ( $LastExitCode -ne 0 ) {
Write-Output "ERROR" "ERROR" "ERROR"
} else {
Write-Output "DONE" "DONE" "DONE"
}
}
# Taken from fio_latency2csv.py
function plat_idx_to_val( $idx, $FIO_IO_U_PLAT_BITS, $FIO_IO_U_PLAT_VAL )
{
# MSB <= (FIO_IO_U_PLAT_BITS-1), cannot be rounded off. Use
# all bits of the sample as index
if ($idx -lt ($FIO_IO_U_PLAT_VAL -shl 1)) {
return $idx
}
# Find the group and compute the minimum value of that group
$error_bits = ($idx -shr $FIO_IO_U_PLAT_BITS) - 1
$base = 1 -shl ($error_bits + $FIO_IO_U_PLAT_BITS)
# Find its bucket number of the group
$k = $idx % $FIO_IO_U_PLAT_VAL
# Return the mean of the range of the bucket
return ($base + (($k + 0.5) * (1 -shl $error_bits)))
}
function WriteExceedance($j, $rdwr, $outfile)
{
# Generate an exceedance CSV for read or write from JSON output.
if ($fioOutputFormat -eq "json") {
return # This data not present in JSON format, only JSON+
}
$ios = $j.jobs[0].$rdwr.total_ios
if ( $ios -gt 0 ) {
$runttl = 0;
# FIO 2.99 changed this to use saner latency bucketing, no semi-log needed
if ($j.jobs[0].$rdwr.clat_ns) {
# This is very inefficient, but need to convert from object.property's to sorted ints...
$lat_ns = @()
foreach ($n in ((Get-Member -inputObject $j.jobs[0].$rdwr.clat_ns.bins -MemberType Properties).name) ) {
$lat_ns += [long]$n
}
foreach ($b in ($lat_ns | sort-object)) {
$lat_us = [float]($b) / 1000.0
$cnt = [int]$j.jobs[0].$rdwr.clat_ns.bins.$b
$runttl += $cnt
$pctile = 1.0 - [float]$runttl / [float]$ios;
if ( $cnt -gt 0 ) {
"$lat_us,$pctile" >> $outfile
}
}
} else {
$plat_bits = $j.jobs[0].$rdwr.clat.bins.FIO_IO_U_PLAT_BITS
$plat_val = $j.jobs[0].$rdwr.clat.bins.FIO_IO_U_PLAT_VAL
foreach ($b in 0..[int]$j.jobs[0].$rdwr.clat.bins.FIO_IO_U_PLAT_NR) {
$cnt = [int]$j.jobs[0].$rdwr.clat.bins.$b
$runttl += $cnt
$pctile = 1.0 - [float]$runttl / [float]$ios
if ( $cnt -gt 0 ) {
$p2idx = plat_idx_to_val $b $plat_bits $plat_val
"${p2idx},${pctile}" >> $outfile
}
}
}
}
}
function CombineThreadOutputs($suffix, $outcsv, $lat, $runtime, $extra_runtime)
{
# Merge all FIO iops/lat logs across all servers"""
# The lists may be called "iops" but the same works for clat/slat
$testtime = $runtime + $extra_runtime
$iops = New-Object 'float[]' $testtime
# For latencies, need to keep the _w and _r separate
$iops_w = New-Object 'float[]' $testtime
$filecnt = 0
$fileglob = "$testfile$suffix.*log"
Get-ChildItem $fileglob | ForEach-Object {
$filename = $_.FullName
$filecnt++
$csvhdr = 'timestamp', 'value', 'wr', 'ign'
$lines = Import-Csv -Path $filename -Header $csvhdr
$lineidx = 0
# Set time 0 IOPS to first values
$riops = [float]0.0
$wiops = [float]0.0
$nexttime = [float]0.0
for ($x=0; $x -lt $testtime; $x++) {
if ( -not $lat ) {
$iops[$x] = [float]$iops[$x] + [float]$riops + [float]$wiops
} else {
$iops[$x] = [float]$iops[$x] + [float]$riops
$iops_w[$x] = [float]$iops_w[$x] + [float]$wiops
}
while (($lineidx -lt $lines.Count) -and ($nexttime -lt $x)) {
$nexttime = $lines[$lineidx].timestamp / 1000.0
if ( $lines[$lineidx].wr -eq 1 ) {
$wiops = [int]$lines[$lineidx].value
} else {
$riops = [int]$lines[$lineidx].value
}
$lineidx++
}
}
}
# Generate the combined CSV
for ($x=[int]($extra_runtime / 2); $x -lt ($runtime + $extra_runtime); $x++) {
if ( $lat ) {
$a = [float]$iops[$x] / [float]$filecnt
$b = [float]$iops_w[$x] / [float]$filecnt
"{0:f1},{1:f1}" -f $a, $b >> $outcsv
} else {
$a = $iops[$x]
"{0:f0}" -f $a >> $outcsv
}
}
}
function RunTest
{
# Runs the specified test, generates output CSV lines.
# Output file names
$testfile = TestName $seqrand $wmix $bs $threads $iodepth
if ( $seqrand -eq "Seq" ) { $rw = "rw" }
else { $rw = "randrw" }
if ( $iops_log ) {
$extra_runtime = 10
} else {
$extra_runtime = 0
}
$testtime = $runtime + $extra_runtime
$cmd = ("--name=test", "--readwrite=$rw", "--rwmixwrite=$wmix")
$cmd += ("--bs=$bs", "--invalidate=1", "--end_fsync=0")
$cmd += ("--group_reporting", "--direct=1", "--filename=$physDrive")
$cmd += ("--size=${testcapacity}G", "--time_based", "--runtime=$testtime")
$cmd += ("--ioengine=$ioengine", "--numjobs=$threads")
$cmd += ("--iodepth=$iodepth", "--norandommap", "--randrepeat=0")
if ( $iops_log ) {
$cmd += ("--write_iops_log=$testfile")
$cmd += ("--write_lat_log=$testfile")
$cmd += ("--log_avg_msec=1000")
$cmd += ("--log_unix_epoch=0")
}
$cmd += ("--thread", "--output-format=$fioOutputFormat", "--exitall")
$fio + " " + [string]::Join(" ", $cmd) | Out-File $testfile
# Check that the IO size is usable. Some SSDs are only 4K logical sectors
$minblock = (Get-Disk | Where-Object { $_.Number -eq $global:physDriveNo }).LogicalSectorSize
if ( $bs -lt $minblock ) {
"Test not run because block size $bs below minimum size $minblock" | Out-File -Append $testfile
"3;" + "0;" * 100 | Out-File -Append $testfile # Bogus 0-filled result line
"1,1" | Out-File "${testfile}.exc.read.csv"
"1,1" | Out-File "${testfile}.exc.write.csv"
"$seqrand,$wmix,$bs,$threads,$iodepth,0,0,0,0" | Out-File -Append $testcsv
Write-Output "SKIP" "SKIP" "SKIP"
return
}
. $fio @cmd | Out-File -Append $testfile
if ( $LastExitCode -ne 0 ) {
Write-Output "ERROR" "ERROR" "ERROR"
return # Don't process this one, it was error'd out!
}
if ( $iops_log ) {
CombineThreadOutputs '_iops' $timeseriescsv $false $runtime $extra_runtime
CombineThreadOutputs '_clat' $timeseriesclatcsv $true $runtime $extra_runtime
CombineThreadOutputs '_slat' $timeseriesslatcsv $true $runtime $extra_runtime
}
# Thanks to @BryanTuttle. Skip any FIO output before the JSON open-bracket
$LineSkip=0
foreach ($line in Get-Content $testfile) {
if ($line -match '^{') { break }
else {$LineSkip++}
}
$j = ConvertFrom-Json "$(Get-Content $testfile | select -Skip $LineSkip)"
$rdiops = [float]($j.jobs[0].read.iops);
$wriops = [float]($j.jobs[0].write.iops);
$rlat = [float]($j.jobs[0].read.lat_ns.mean) / 1000.0;
if ($rlat -le 0.0001) { $rlat = [float]($j.jobs[0].read.lat.mean); }
$wlat = [float]($j.jobs[0].write.lat_ns.mean) / 1000.0;
if ($wlat -le 0.0001) { $wlat = [float]($j.jobs[0].wlat.lat.mean); }
$iops = "{0:F0}" -f ($rdiops + $wriops)
# Locale output is not wanted here, manually make a decimal string. Ugh
$lat = "{0:F1}" -f ([math]::Max($rlat, $wlat))
$mbpsfloat = (( ($rdiops+$wriops) * $bs ) / ( 1024.0 * 1024.0 ))
"{0:f1}" -f $mbpsfloat | Set-Variable mbps
$lat = "{0:F1}" -f ([math]::Max($rlat, $wlat)) # This is just displayed, use native locale
"$seqrand,$wmix,$bs,$threads,$iodepth,$iops,$mbps,$rlat,$wlat" | Out-File -Append $testcsv
WriteExceedance $j "read" "${testfile}.exc.read.csv"
WriteExceedance $j "write" "${testfile}.exc.write.csv"
Write-Output $iops $mbps $lat
}
'@
function DefineTests {
# Generate the work list for the main worker into OC.
# What we're shmoo-ing across
$bslist = (512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072)
$qdlist = (1, 2, 4, 8, 16, 32, 64, 128, 256)
$threadslist = (1, 2, 4, 8, 16, 32, 64, 128, 256)
$shorttime = 120 # Runtime of point tests
$longtime = 1200 # Runtime of long-running tests
if ( $quickie ) {
$shorttime = [int]($shorttime / 10)
$longtime = [int]($longtime / 10)
}
function AddTest( $name, $seqrand, $writepct, $blocksize, $threads, $qdperthread, $desc, $cmdline ) {
if ($threads -eq "") { $qd = '' } else { $qd = ([int]$threads) * ([int]$qdperthread) }
if ($blocksize -ne "") { if ($blocksize -lt 1024) { $bsstr = "${blocksize}b" } else { $bsstr = "{0:N0}K" -f ([int]$blocksize/1024) } }
if ($writepct -ne "" ) { $writepct = [string]$writepct + "%" }
$dat = New-Object psobject -Property @{ name=$name; seqrand=$seqrand; writepct=$writepct
bs=$bsstr; qd = $qd; qdperthread = $qdperthread; bw = ''; iops= ''; lat = ''; desc = $desc;
cmdline = $cmdline }
$global:oc.Add( $dat )
}
function DoAddTest {
AddTest $testname $seqrand $wmix $bs $threads $iodepth $desc "$global:globals; $global:jobutils; `$iops_log=$iops_log; `$seqrand=`"$seqrand`"; `$wmix=$wmix; `$bs=$bs; `$threads=$threads; `$iodepth=$iodepth; `$runtime=$runtime; RunTest"
}
function AddTestBSShmoo {
AddTest $testname 'Preparation' '' '' '' '' '' "$global:globals; `"$testname`" >> `"$global:testcsv`"; Write-Output ' ' ' ' ' '"
foreach ($bs in $bslist ) { $desc = "$testname, BS=$bs"; DoAddTest }
}
function AddTestQDShmoo {
AddTest $testname 'Preparation' '' '' '' '' '' "$global:globals; `"$testname`" >> `"$global:testcsv`"; Write-Output ' ' ' ' ' '"
foreach ($iodepth in $qdlist ) { $desc = "$testname, QD=$iodepth"; DoAddTest }
}
function AddTestThreadsShmoo {
AddTest $testname 'Preparation' '' '' '' '' '' "$global:globals; `"$testname`" >> `"$global:testcsv`"; Write-Output ' ' ' ' ' '"
foreach ($threads in $threadslist) { $desc = "$testname, Threads=$threads"; DoAddTest }
}
AddTest 'Sequential Preconditioning' 'Seq Pass 1' '100' '131072' '1' '256' 'Sequential Preconditioning' "$global:globals; $global:jobutils; SequentialConditioning;"
if ($global:fastPrecond -ne $true) {
AddTest 'Sequential Preconditioning' 'Seq Pass 2' '100' '131072' '1' '256' 'Sequential Preconditioning' "$global:globals; $global:jobutils; SequentialConditioning;"
}
$testname = "Sustained Multi-Threaded Sequential Read Tests by Block Size"
$seqrand = "Seq"; $wmix=0; $threads=1; $runtime=$shorttime; $iops_log="`$false"; $iodepth=256
AddTestBSShmoo
$testname = "Sustained Multi-Threaded Random Read Tests by Block Size"
$seqrand = "Rand"; $wmix=0; $threads=16; $runtime=$shorttime; $iops_log="`$false"; $iodepth=16
AddTestBSShmoo
$testname = "Sequential Write Tests with Queue Depth=1 by Block Size"
$seqrand = "Seq"; $wmix=100; $threads=1; $runtime=$shorttime; $iops_log="`$false"; $iodepth=1
AddTestBSShmoo
if ($global:fastPrecond -ne $true) {
AddTest 'Random Preconditioning' 'Rand Pass 1' '100' '4096' '1' '256' 'Random Preconditioning' "$global:globals; $global:jobutils; RandomConditioning;"
AddTest 'Random Preconditioning' 'Rand Pass 2' '100' '4096' '1' '256' 'Random Preconditioning' "$global:globals; $global:jobutils; RandomConditioning;"
}
$testname = "Sustained 4KB Random Read Tests by Number of Threads"
$seqrand = "Rand"; $wmix=0; $bs=4096; $runtime=$shorttime; $iops_log="`$false"; $iodepth=1
AddTestThreadsShmoo
$testname = "Sustained 4KB Random mixed 30% Write Tests by Number Threads"
$seqrand = "Rand"; $wmix=30; $bs=4096; $runtime=$shorttime; $iops_log="`$false"; $iodepth=1
AddTestThreadsShmoo
$testname = "Sustained Perf Stability Test - 4KB Random 30% Write for 20 minutes"
$desc = $testname
AddTest $testname 'Preparation' '' '' '' '' '' "$global:globals; `"$testname`" >> `"$global:testcsv`"; Write-Output ' ' ' ' ' '"
$seqrand = "Rand"; $wmix=30; $bs=4096; $runtime=$longtime; $iops_log="`$true"; $iodepth=1; $threads=256
DoAddTest
$testname = "Sustained 4KB Random Write Tests by Number of Threads"
$seqrand = "Rand"; $wmix=100; $bs=4096; $runtime=$shorttime; $iops_log="`$false"; $iodepth=1
AddTestThreadsShmoo
$testname = "Sustained Multi-Threaded Random Write Tests by Block Size"
$seqrand = "Rand"; $wmix=100; $runtime=$shorttime; $iops_log="`$false"; $iodepth=16; $threads=16
AddTestBSShmoo
}
function RunAllTests()
{
# Iterate through the OC work queue and run each job, show progress.
function UpdateView {
# Updates the grid to reflect new data, scrolls to selection
$t_testList.ItemsSource.Refresh()
$t_testList.UpdateLayout()
$t_testList.ScrollIntoView($t_testList.SelectedItem)
}
function NotifyIcon {
# NotifyIcon needs to run as separate Powerhell process because
# a WPF form will block other events (like the notify-clicked) until
# it returns control to PowerShell
# Pass destination into the block through the child's environment
[System.Environment]::SetEnvironmentVariable("ods", $global:odsdest)
$proc = Start-Process -PassThru (Get-Command powershell.exe) -WindowStyle Hidden -ArgumentList ( "-Command", {
Add-Type -AssemblyName PresentationFramework, System.Windows.Forms
echo ([System.Environment]::GetEnvironmentVariable("'ods'"))
# Add a NotifyIcon that, when clicked, will open the results spreadsheet
$global:notify = New-Object System.Windows.Forms.NotifyIcon
$global:notify.Icon = [System.Drawing.SystemIcons]::Information
$global:notify.BalloonTipIcon = "'Info'"
$global:notify.BalloonTipText = "'The ezFIO test series has completed and result spreadsheet may be opened.'"
$global:notify.Text = "'Click to open the ezFIOresult spreadsheet'"
$global:notify.BalloonTipTitle = "'ezFIO Test Completion'"
$global:notify.Visible = $True
# Using the add_BalloonTipClicked() seemed to fault every time
Unregister-Event -SourceIdentifier click_event -ErrorAction SilentlyContinue
Register-ObjectEvent $notify Click -sourceIdentifier click_event -Action {
Invoke-Item ([System.Environment]::GetEnvironmentVariable("'ods'"))
$global:notify.Dispose()
$global:notify = $null
} | Out-Null
Unregister-Event -SourceIdentifier balloonclick_event -ErrorAction SilentlyContinue
Register-ObjectEvent $notify BalloonTipClicked -SourceIdentifier balloonclick_event -Action {
Invoke-Item ([System.Environment]::GetEnvironmentVariable("'ods'"))
$global:notify.Dispose()
$global:notify = $null
} | Out-Null
$notify.ShowBalloonTip(10000)
while ( $global:notify -ne $null ) { sleep 1 }
} )
return $proc
}
$xaml = @'
<Window x:Class="Window3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ezFIO Test Progress" Height="562.084" Width="682.007">
<Window.Resources>
<Style x:Key="CellRightAlign">
<Setter Property="Control.HorizontalAlignment" Value="Right" />
</Style>
<Style x:Key="CellCenterAlign">
<Setter Property="Control.HorizontalAlignment" Value="Center" />
</Style>
</Window.Resources>
<Grid>
<Label Content="Testing Drive:" HorizontalAlignment="Left" Margin="83,23,0,0" VerticalAlignment="Top"/>
<Label x:Name="testingDrive" Content="\\physicaldrive0" HorizontalAlignment="Left" Margin="167,23,0,0" VerticalAlignment="Top"/>
<Label Content="Current Test Runtime:" HorizontalAlignment="Left" Margin="40,75,0,0" VerticalAlignment="Top"/>
<Label x:Name="testRuntime" Content="00:00:00" HorizontalAlignment="Left" Margin="167,75,0,0" VerticalAlignment="Top"/>
<Label Content="Current Test:" HorizontalAlignment="Left" Margin="88,49,0,0" VerticalAlignment="Top"/>
<Label x:Name="currentTest" Content="BS 4K, QD 32, WR 100%" HorizontalAlignment="Left" Margin="167,49,0,0" VerticalAlignment="Top"/>
<DataGrid x:Name="testList" HorizontalAlignment="Left" Margin="36,146,0,0" VerticalAlignment="Top" Height="321" Width="600" GridLinesVisibility="None" HeadersVisibility="Column">
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Items[0].name}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</DataGrid.GroupStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Access Pattern" Binding="{Binding seqrand}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true"/>
<DataGridTextColumn Header="Write %" Binding="{Binding writepct}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
<DataGridTextColumn Header="Block Size" Binding="{Binding bs}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
<DataGridTextColumn Header="Queue Depth" Binding="{Binding qd}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
<DataGridTextColumn Header=" " Binding="{Binding blank}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
<DataGridTextColumn Header="IOPS" Binding="{Binding iops}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
<DataGridTextColumn Header="Bandwidth (MB/s)" Binding="{Binding bw}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
<DataGridTextColumn Header="Latency (us)" Binding="{Binding lat}" CanUserSort="false" CanUserReorder="false" IsReadOnly="true" ElementStyle="{StaticResource CellRightAlign}"/>
</DataGrid.Columns>
</DataGrid>
<Button x:Name="openSpreadsheet" Content="Open Graphs Spreadsheet" HorizontalAlignment="Left" Margin="236,486,0,0" Width="200" Height="27" VerticalAlignment="Top"/>
<Label Content="Total Test Runtime:" HorizontalAlignment="Left" Margin="53,102,0,0" VerticalAlignment="Top"/>
<Label x:Name="totalRuntime" Content="00:00:00" HorizontalAlignment="Left" Margin="167,102,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>
'@
# The test window
$t = WindowFromXAML $xaml 't'
$t.Icon = $global:iconBitmap
$t.add_Loaded( {
$t.Activate()
$t_testList.Focus()
$global:step = -1 # Which test we're on
$global:curjob = $null # Which process is running
$global:totalStarttime = Get-Date
# The NotifyIcon process info
$global:notifyProc = $null
$t_testingDrive.Content = [string]::Format("{0}, {1}({2}), {3}GB", $global:physDrive, $global:model, $global:serial, $global:testcapacity )
$t_openSpreadsheet.IsEnabled = $false
$t_currentTest.Content = "Starting up..."
$t_testList.CanUserAddRows = $false
$t_testList.AutoGenerateColumns = $false
$t_testList.ItemsSource = $null
$lview = [System.Windows.Data.ListCollectionView]$global:oc
$lview.GroupDescriptions.Add((new-object System.Windows.Data.PropertyGroupDescription "name"))
$t_testList.ItemsSource = $lview
# Poor man's threading/event driven
$global:timer = new-object System.Windows.Threading.DispatcherTimer
$global:timer.Interval = [TimeSpan]"0:0:1.00"
$global:timer.Add_Tick(
{
# If there's a running job, update the runtime if not done, and capture the results if finished
if ($global:curjob -ne $null)
{
if ( $global:curjob.State -match 'running' )
{
$now = Get-Date
$delta = $now - $global:starttime
$ts = [timespan]::FromTicks($delta.Ticks)
$t_testRuntime.Content = $ts.ToString("hh\:mm\:ss")
$delta = $now - $global:totalstarttime
$ts = [timespan]::FromTicks($delta.Ticks)
$t_totalRuntime.Content = $ts.ToString("hh\:mm\:ss")
} else {
# Job just finished, let's read out answers
$q = Receive-Job $global:curjob
$global:oc[$global:step].iops = $q[0]
$global:oc[$global:step].bw = $q[1]
$global:oc[$global:step].lat = $q[2]
$ign = 0.0
if ([float]::TryParse($global:oc[$global:step].iops, [ref]$ign)) { $global:oc[$global:step].iops = [string]::Format("{0:N0}", [float]$global:oc[$global:step].iops) }
if ([float]::TryParse($global:oc[$global:step].bw, [ref]$ign)) { $global:oc[$global:step].bw = [string]::Format("{0:N1}", [float]$global:oc[$global:step].bw) }
$t_testList.SelectedIndex = $global:step
UpdateView
if ($global:oc[$global:step].iops -eq "ERROR") {
$global:step = 9999 # Skip all the other tests
[System.Windows.Forms.MessageBox]::Show( "ERROR! FIO job did not complete successfully. Aborting further runs.", "Fatal Error", 0, 48 ) | Out-Null
}
}
}
# If there's no running job (last one finished), start a new one
if ( ($global:curjob -eq $null) -or ( -not ($global:curjob.State -match 'running' ) ) ){
$global:step = $global:step + 1
if ($global:step -lt $t_testList.Items.Count) {
$t_testList.SelectedIndex = $global:step
$global:cmdline = $t_testList.Items[$global:step].cmdline
$t_currentTest.Content = $t_testList.Items[$global:step].desc
# Powershell won't have the $globals in the Start-Job context, so expand here
$fullcmd = "Start-Job { $global:cmdline }"
$global:curjob = Invoke-Expression $fullcmd
$global:starttime = Get-Date
$global:oc[$global:step].iops = "Running"
$global:oc[$global:step].bw = "Running"
$global:oc[$global:step].lat = "Running"
$t_testList.SelectedIndex = $global:step
UpdateView
} else {
$global:timer.Stop()
$global:curjob = $null
$t_testList.SelectedIndex = $null
if ($global:step -lt 9999) {
$t_currentTest.Content = "Completed"
GenerateResultODS
$t_openSpreadsheet.IsEnabled = $true
$global:notifyProc = NotifyIcon
} else {
$t_currentTest.Content = "ERROR"
}
}
}
} )
$global:timer.Start()
} )