-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.ps1
40 lines (32 loc) · 1.31 KB
/
benchmark.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
# Usage: ./benchmark.ps1 {dataset-folder}
$exe_folder = ".\x64\Release"
$programs = "PrimBinaryHeap","PrimKHeap","KruskalUnionFind","KruskalUnionFindCompressed","KruskalNaive"
$output_folder = ".\benchmark"
$datasets = "datasets"
if($args[0] -ne $null) {
$datasets = $args[0]
}
# necessary to ensure all [io.file] methods are relative to this directory instead
# of "C:\Windows\System 32"
[System.IO.Directory]::SetCurrentDirectory($PWD)
foreach ($program in $programs) {
$timestamp = $(get-date -f "yyyyMMdd_HHmmss_ff")
$output_filename = "$program.$timestamp.csv"
$destination = "$output_folder\$output_filename"
echo "Benchmark start: $program"
# [io.file] methods are used to avoid newlines on append.
# The first write has to be performed with [io.file] too:
# using echo would result in corrupt characters in [io.file]::AppendAllText.
[io.file]::WriteAllText($destination, "ms;output;n;m;filename")
[io.file]::AppendAllText($destination, [Environment]::NewLine)
Get-ChildItem "./" -Filter "$datasets/*.txt" |
Foreach-Object {
$filename = $_.FullName
$basename = $_.Basename
echo "$basename.txt"
(& .\time.ps1 "$exe_folder\$program" $filename) | Out-String | Tee-Object -variable out
[io.file]::AppendAllText($destination, $out)
}
echo "Benchmark end: $program"
echo ""
}