-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummarize.ps1
103 lines (94 loc) · 3.29 KB
/
summarize.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
Function ConvertTo-Markdown {
<#
.Synopsis
Converts a PowerShell object to a Markdown table.
.EXAMPLE
$data | ConvertTo-Markdown
.EXAMPLE
ConvertTo-Markdown($data)
#>
[CmdletBinding()]
[OutputType([string])]
Param (
[Parameter(
Mandatory = $true,
Position = 0,
ValueFromPipeline = $true
)]
[PSObject[]]$collection
)
Begin {
$items = @()
$columns = [ordered]@{}
}
Process {
ForEach($item in $collection) {
$items += $item
$item.PSObject.Properties | %{
if(-not $columns.Contains($_.Name) -or $columns[$_.Name] -lt $_.Value.ToString().Length) {
$columns[$_.Name] = $_.Value.ToString().Length
}
}
}
}
End {
ForEach($key in $($columns.Keys)) {
$columns[$key] = [Math]::Max($columns[$key], $key.Length)
}
$header = @()
ForEach($key in $columns.Keys) {
$header += ('{0,-' + $columns[$key] + '}') -f $key
}
$header -join ' | '
$separator = @()
ForEach($key in $columns.Keys) {
$separator += '-' * $columns[$key]
}
$separator -join ' | '
ForEach($item in $items) {
$values = @()
ForEach($key in $columns.Keys) {
$values += ('{0,-' + $columns[$key] + '}') -f $item.($key)
}
$values -join ' | '
}
}
}
$directory = "180313_5b08fb1f_i7-8700_nietras\"
$filePathSearch = $directory + "*SortBench-report.csv"
$filePathSearch
$files = Get-ChildItem -Path $filePathSearch
$files
$csvs = $files | ForEach-Object -Process { Import-Csv -Path $PSItem.FullName }
$groups = $csvs | Group-Object -Property Method,Filler,Length
#$groups
#$summaries = $groups | Select-Object -Unique -Property Name @{
# Label = "Mean";
# Expression = {
# # Sum all the counts for each domain
# ($PSItem.group | Measure-Object -Property Scaled -Mean).Mean
# }
# }
#$summaries = $groups | Select-Object -expandproperty Scaled
#$summaries
#$groups | ForEach-Object { $_.Name }
#$groups | ForEach-Object { ($_.Group | Measure-Object -Property Scaled -Min -Average -Max) }
#Group-Object -Property Method,Filler,Length | Select-Object -Unique -Property Name @{
# Label = "Mean";
# Expression = {
# # Sum all the counts for each domain
# ($PSItem.Group | Measure-Object -Property Scaled -Mean).Mean
# }
# }
$r = $groups |
Select-Object @{ Name='Method' ;Expression={$_.Name.Split(',')[0] } },
@{ Name='Filler' ;Expression={$_.Name.Split(',')[1] } },
@{ Name='Length' ;Expression={$_.Name.Split(',')[2] } },
@{ Name='Min';Expression={($_.Group|Measure-Object -Property Scaled -Min).Minimum} },
@{ Name='Mean';Expression={($_.Group|Measure-Object -Property Scaled -Average).Average} },
@{ Name='Max';Expression={($_.Group|Measure-Object -Property Scaled -Max).Maximum} }
#$r
#$r | Export-Csv -NoTypeInformation -Path ..\SortBench-summary-report.csv
$outputFilePath = $directory + "SortBench-summary-report.md"
$r | ConvertTo-Markdown | Out-File $outputFilePath
$outputFilePath