-
Notifications
You must be signed in to change notification settings - Fork 98
/
run.ps1
executable file
·118 lines (109 loc) · 2.81 KB
/
run.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
# Read the first arg passed to the script
$first_arg = $args[0]
$HYPER = 0
if (Get-Command hyperfine -ErrorAction SilentlyContinue) {
$HYPER = 1
}
$EXT = if ([System.Environment]::OSVersion.Platform -eq "Unix") {
""
} else {
".exe"
}
function run_go {
Write-Output "Running Go"
Set-Location ./go
$env:GOEXPERIMENT='arenas'
go build
if ($HYPER -eq 1) {
hyperfine -r 10 -w 5 --show-output "./related$EXT"
}
else {
Measure-Command { "./related$EXT" }
}
check_output "related_posts_go.json"
}
function run_python {
Write-Output "Running Python"
Set-Location ./python
if (!(Test-Path "./venv")) {
python3 -m venv venv
}
venv\Scripts\activate
if ($HYPER -eq 1) {
hyperfine -r 5 --show-output "python3 ./related.py"
}
else {
Measure-Command { python3 ./related.py }
}
deactivate
check_output "related_posts_python.json"
}
function run_js {
param($title)
Write-Output "Running $title"
Set-Location ./js
if ($HYPER -eq 1) {
if ($title -eq "deno") {
hyperfine -r 5 --show-output "deno run --allow-read --allow-write deno.js"
}
else {
hyperfine -r 5 --show-output "$title $title.js"
}
}
else {
Measure-Command { & $title "$title.js" }
}
check_output "related_posts_$title.json"
}
function run_fsharp {
Write-Output "Running FSharp"
Set-Location ./fsharp
dotnet restore
dotnet publish -c release
if ($HYPER -eq 1) {
hyperfine -r 5 -w 2 --show-output "./bin/release/net7.0/fsharp$EXT"
}
else {
Measure-Command { "./bin/release/net7.0/fsharp$EXT" }
}
check_output "related_posts_fsharp.json"
}
function run_csharp {
Write-Output "Running CSharp"
Set-Location ./csharp
dotnet restore
dotnet publish -c release --self-contained -o "bin/release/net7.0/publish"
if ($HYPER -eq 1) {
hyperfine -r 5 -w 2 --show-output "./bin/release/net7.0/publish/related$EXT"
}
else {
Measure-Command { "./bin/release/net7.0/publish/related$EXT" }
}
check_output "related_posts_csharp.json"
}
function check_output {
param($file)
Set-Location ..
Write-Output "Checking output"
python3 verify.py $file
}
switch($first_arg) {
"go" { run_go }
"py" { run_python }
"node" { run_js "node" }
"bun" { run_js "bun" }
"deno" { run_js "deno" }
"fsharp" { run_fsharp }
"csharp" { run_csharp }
"all" {
Write-Output "Running all"
run_go
run_python
run_js "node"
run_js "bun"
run_js "deno"
run_fsharp
Write-Output "Finished running all"
}
default { Write-Output "Valid args: go | py | node | bun | deno | fsharp | csharp | all . Unknown argument: $first_arg" }
}