-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_numbers.ps1
155 lines (127 loc) · 6.44 KB
/
run_numbers.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
# $vcvars_dir = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
$vcvars_dir = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\Build\vcvars64.bat"
$vcpkg_dir = "C:\inc\vcpkg-master"
$tracy_dir = "..\common_libs\tracy"
$vulkan_dir = "C:\VulkanSDK\1.2.162.1\Include"
$boost_dir = "C:\boost_1_76_0"
function Invoke-CmdScript {
param(
[String] $script_path
)
Write-Output "running script $script_path"
$cmdLine = """$script_path"" $args & set"
& $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
select-string '^([^=]*)=(.*)$' | foreach-object {
$varName = $_.Matches[0].Groups[1].Value
$varValue = $_.Matches[0].Groups[2].Value
set-item Env:$varName $varValue
}
}
if((-Not (Test-Path env:cpp_lit_invoked_vcvars)) -And (-Not $env:cpp_lit_invoked_vcvars)){
Invoke-CmdScript -script_path $vcvars_dir
# prevent running that script more than once per session. It's slow and there's an issue with multiple invokations
$env:cpp_lit_invoked_vcvars = $true
}
$include_statement = "/I" + $vcpkg_dir + "\installed\x64-windows\include " + "/I" + $tracy_dir + " /I" + $vulkan_dir + " /I" + $boost_dir + " "
function Setup-Tus{
Param(
[Parameter(Mandatory=$true)] $tu_count
)
For ($i=0; $i -lt $tu_count; $i++){
Copy-Item build_project\template.cpp -Destination ("build_project\tu{0}.cpp" -f $i)
}
}
function del_main{
while($true){
try{
Remove-Item -Path main.*
Remove-Item -Path tu*.obj
return
}
catch{
Write-Host "error, retrying" -ForegroundColor Red
}
}
}
function Invoke-Meas{
Param(
[Parameter(Mandatory=$true)] $description,
[Parameter(Mandatory=$true)] $inc,
[Parameter(Mandatory=$true)] $repeats,
[Parameter(Mandatory=$false)] [string[]]$defines,
[Parameter(Mandatory=$true)] $tu_count
)
$extra_defines_str = ""
foreach ($d in $defines){
$extra_defines_str += "/D " + $d + " "
}
$sources_str = "build_project/main.cpp"
For ($i=0; $i -lt $tu_count; $i++){
$sources_str += " build_project\tu{0}.cpp" -f $i
}
$cl_command = "CL " + $include_statement + "/O2 /GL /Oi /MD /D NDEBUG " + $extra_defines_str + " /std:c++latest /experimental:module /EHsc /nologo " + $sources_str + " /link /MACHINE:X64 /LTCG:incremental"
For ($i=0; $i -lt $repeats; $i++){
Write-Host -NoNewLine ("`rdescription: {0}, inc: {1}, defines: {2}, i:{3}/{4}" -f $description, $inc, [system.String]::Join(" ", $defines), $i, $repeats) -ForegroundColor DarkGreen
if($description -eq "warmup"){
Invoke-Expression $cl_command | out-null
}
else{
Measure-Command {
Invoke-Expression $cl_command
} | Out-File -FilePath ("measurements\$description-$inc-" + $tu_count + ".txt") -Append -Encoding utf8
}
if(-Not(Test-Path "main.exe")){
Write-Host ("no main.exe! desc: {0}, inc: {1}. Printing output, then exiting" -f $description, $inc) -ForegroundColor Red
Invoke-Expression $cl_command
del_main
exit
}
del_main
}
Write-Host ""
}
$std_headers = "algorithm","any","array","atomic","barrier","bit","bitset","cassert","cctype","cerrno","cfenv","cfloat","charconv","chrono","cinttypes","climits","clocale","cmath","compare","complex","concepts","condition_variable","coroutine","csetjmp","csignal","cstdarg","cstddef","cstdint","cstdio","cstdlib","cstring","ctime","cuchar","cwchar","cwctype","deque","exception","execution","filesystem","format","forward_list","fstream","functional","future","initializer_list","iomanip","ios","iosfwd","iostream","istream","iterator","latch","limits","list","locale","map","memory","memory_resource","mutex","new","numbers","numeric","optional","ostream","queue","random","ranges","ratio","regex","scoped_allocator","semaphore","set","shared_mutex","source_location","span","sstream","stack","stdexcept","stop_token","streambuf","string","string_view","syncstream","system_error","thread","tuple","type_traits","typeindex","typeinfo","unordered_map","unordered_set","utility","valarray","variant","vector","version"
$std_modules = "std_regex","std_filesystem","std_memory","std_threading","std_core"
$third_party_libs = @()
# $third_party_libs += "windows","windows_mal"
# $third_party_libs += "tracy"
# $third_party_libs += "vulkan"
# $third_party_libs += "vulkanhpp"
# $third_party_libs += "spdlog"
# $third_party_libs += "fmt"
# $third_party_libs += "nl_json_fwd","nl_json"
# $third_party_libs += "glm"
# $third_party_libs += "stb_image"
# $third_party_libs += "stb_image_write"
$third_party_libs += "entt"
# $third_party_libs += "boost_json"
# $third_party_libs += "boost_variant"
# $third_party_libs += "boost_variant2"
# Clean measurements output dir
# if(Test-Path measurements){
# Remove-Item measurements -Recurse
# }
new-item -Name measurements -ItemType directory -Force | out-null
Write-Host "Start:" (get-date).ToString('T') -ForegroundColor DarkGreen
Setup-Tus -tu_count 10
# Invoke-Meas -description "warmup" -inc "warmup" -repeats 5 -defines @() -tu_count 50
# Invoke-Meas -description "special" -inc "baseline" -repeats 40 -defines @("no_std") -tu_count 50
# Invoke-Meas -description "special" -inc "baseline" -repeats 40 -defines @("no_std") -tu_count 50
# Invoke-Meas -description "std" -inc "filesystem" -repeats 40 -defines @("no_std", "i_filesystem") -tu_count 1
# Invoke-Meas -description "std" -inc "filesystem" -repeats 40 -defines @("no_std", "i_filesystem") -tu_count 1
Invoke-Meas -description "warmup" -inc "warmup" -repeats 40 -defines @() -tu_count 10
# Invoke-Meas -description "special" -inc "baseline" -repeats 40 -defines @() -tu_count 10
$normal_repeat_n = 10
# Foreach($header in $std_headers){
# $def = "i_{0}" -f $header
# Invoke-Meas -description "std" -inc $header -repeats $normal_repeat_n -defines @($def) -tu_count 10
# }
# Foreach($header in $std_modules){
# $def = "i_{0}" -f $header
# Invoke-Meas -description "std_modules" -inc $header -repeats $normal_repeat_n -defines @($def) -tu_count 10
# }
Foreach($header in $third_party_libs){
$def = "i_{0}" -f $header
Invoke-Meas -description "third_party" -inc $header -repeats $normal_repeat_n -defines @($def) -tu_count 10
}
Write-Host "End:" (get-date).ToString('T') -ForegroundColor DarkGreen