Skip to content

Commit ce33434

Browse files
committed
Add Janet and Rust Script, add a bar-chart, add more related lists
1 parent 294e581 commit ce33434

File tree

9 files changed

+253
-94
lines changed

9 files changed

+253
-94
lines changed

Diff for: .github/workflows/run.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
- name: Set up Guile
4646
run: brew install guile
4747

48+
- name: Set up Janet
49+
run: brew install janet
50+
4851
- name: Set up Julia
4952
run: brew install julia
5053

Diff for: makefile

+6-27
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ print-versions:
6060
@printf '"racket": "%s",\n' "$$(racket --version)"
6161
@printf '"roc": "%s",\n' "$$(roc --version | head -n1)"
6262
@printf '"ruby": "%s",\n' "$$(ruby --version)"
63+
@printf '"rust": "%s",\n' "$$(rustc --version), $$(rust-script --version)"
6364
@printf '"scala": "%s",\n' "$$(scala-cli --version | tr '\n' ',')"
6465
@printf '"stack": "%s",\n' "$$(stack --version)"
6566
@printf '"swift": "%s",\n' \
@@ -77,31 +78,9 @@ run-shebangs:
7778
--shell none \
7879
--warmup 10 \
7980
--export-json result.json \
80-
'./bash' \
81-
'./bun' \
82-
'./dart' \
83-
'./dash' \
84-
'./elixir' \
85-
'./elvish' \
86-
'./fish' \
87-
'./fsharp.fsx' \
88-
'./guile' \
89-
'./haskell' \
90-
'./julia' \
91-
'./ksh' \
92-
'./lua' \
93-
'./luajit' \
94-
'./nushell' \
95-
'./ocaml' \
96-
'./osh' \
97-
'./perl' \
98-
'./php' \
99-
'./python' \
100-
'./racket' \
101-
'./roc.roc' \
102-
'./ruby' \
103-
'./scala' \
104-
'./swift' \
105-
'./v.vsh'
81+
$$(cat _all_.txt)
82+
83+
84+
shebang-scripts/today/chart.svg:
85+
bun run ./shebang-scripts/generate-chart.ts
10686

107-
# TODO: Save result.json

Diff for: readme.md

+101-67
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,83 @@
22

33
Benchmark for interpreted languages.
44

5+
![Barchart for relative execution speed](shebang-scripts/today/chart.svg)
6+
7+
The values for Rust, V, and Haskell are not really representative
8+
as they are compiled on the first run
9+
and Haskell unfortunately does not even cache the compiled binary.
10+
511

612
## Languages
713

14+
- [Bash]
15+
- [Bun]
16+
- [Dart]
17+
- [Dash]
18+
- [Elixir]
19+
- [Elvish]
20+
- [F#]
21+
- [Fish]
22+
- [Guile]
23+
- [Haskell]
824
- JavaScript via
925
- [Node.js]
1026
- [Deno]
1127
- [Bun]
28+
- [Julia]
29+
- [Ksh]
30+
- [Lua]
31+
- [Lua]
32+
- [Nickel]
33+
- [Nix Language]
34+
- [Nushell]
35+
- [OCaml]
36+
- [Osh]
37+
- [Perl]
38+
- [PHP]
1239
- TypeScript via
1340
- [Deno]
1441
- [Bun]
1542
- [Python]
16-
- [Lua]
17-
- [Nickel]
18-
- [Nix Language]
43+
- [Python]
44+
- [Racket]
45+
- [Roc.roc]
46+
- [Ruby]
47+
- [Scala]
48+
- [Swift]
1949
- [Typst]
50+
- [V]
2051

52+
[Bash]: https://www.gnu.org/software/bash/
2153
[Bun]: https://bun.sh/
54+
[Dart]: https://dart.dev/
55+
[Dash]: https://wiki.archlinux.org/title/Dash
2256
[Deno]: https://deno.com/
57+
[Elixir]: https://elixir-lang.org/
58+
[Elvish]: https://elv.sh/
59+
[F#]: https://fsharp.org/
60+
[Fish]: https://fishshell.com/
61+
[Guile]: https://www.gnu.org/software/guile/
62+
[Haskell]: https://www.haskell.org/
63+
[Julia]: https://julialang.org/
64+
[Ksh]: https://www.kornshell.com/
2365
[Lua]: https://www.lua.org/
2466
[Nickel]: https://nickel-lang.org/
2567
[Nix Language]: https://nixos.org/manual/nix/stable/language/
2668
[Node.js]: https://nodejs.org/
69+
[Nushell]: https://www.nushell.sh/
70+
[OCaml]: https://ocaml.org/
71+
[Osh]: https://www.oilshell.org/
72+
[Perl]: https://www.perl.org/
73+
[PHP]: https://www.php.net/
2774
[Python]: https://www.python.org/
75+
[Racket]: https://racket-lang.org/
76+
[Roc.roc]: https://roc-lang.org/
77+
[Ruby]: https://www.ruby-lang.org/
78+
[Scala]: https://www.scala-lang.org/
79+
[Swift]: https://swift.org/
2880
[Typst]: https://typst.app/docs/
81+
[V]: https://vlang.io/
2982

3083

3184
### Workarounds
@@ -37,86 +90,67 @@ Benchmark for interpreted languages.
3790

3891
## Result
3992

40-
### MacBook Pro 14"
93+
Check out the workflow runs for the latest benchmark results.
4194

42-
```yaml
43-
Year: 2021
44-
Chip: Apple M1 Pro
45-
Memory: 16 GB
46-
macOS: 13.6.2
47-
```
4895

49-
On 2024-01-29:
96+
### GitHub's MacOS 14 Runner
97+
98+
#### Bucket Calc
5099

51100
```txt
52-
nickel-lang-cli nickel 1.3.0 (rev Homebre)
53-
Python 3.11.6
54-
Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio
55-
deno 1.39.1 (release, aarch64-apple-darwin)
56-
v8 12.0.267.8
57-
typescript 5.3.3
58-
bun --version
59-
1.0.20
60-
node --version
61-
v20.7.0
62-
hyperfine 1.18.0
63-
64-
===== Running Benchmark =====
65-
66-
Summary
67-
lua bin-calculation.lua ran
68-
4.71 ± 0.39 times faster than nickel export bin-calculation.ncl
69-
5.89 ± 0.50 times faster than bun run bin-calculation.js
70-
6.00 ± 0.51 times faster than bun run bin-calculation.ts
71-
11.09 ± 1.11 times faster than python3 bin-calculation.py
72-
11.82 ± 0.92 times faster than deno run bin-calculation.ts
73-
11.86 ± 1.07 times faster than deno run bin-calculation.js
74-
17.90 ± 1.33 times faster than node bin-calculation.js
101+
lua bucket-calc/main.lua ran
102+
2.96 ± 3.97 times faster than nickel export bucket-calc/main.ncl
103+
3.05 ± 3.98 times faster than bun run bucket-calc/main.js
104+
3.09 ± 4.07 times faster than bun run bucket-calc/main.ts
105+
4.71 ± 5.77 times faster than python3 bucket-calc/main.py
106+
4.76 ± 5.83 times faster than deno run bucket-calc/main.ts
107+
4.80 ± 5.91 times faster than deno run bucket-calc/main.js
108+
8.56 ± 10.56 times faster than node bucket-calc/main.js
109+
24.21 ± 29.52 times faster than
110+
typst query --field=text --one bucket-calc/main.typ
75111
```
76112

77113

78-
### Mac mini
79-
80-
```yaml
81-
Year: 2018
82-
Processor: 3.2 GHz 6-Core Intel Core i7
83-
Memory: 32 GB 2667 MHz DDR4
84-
macOS: 13.6.3
85-
```
86-
87-
On 2024-01-29:
114+
#### Shebang Scripts
88115

89116
```txt
90-
nickel-lang-cli nickel 1.4.0 (rev Homebre)
91-
Python 3.11.7
92-
Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio
93-
deno 1.39.4 (release, x86_64-apple-darwin)
94-
v8 12.0.267.8
95-
typescript 5.3.3
96-
bun --version
97-
1.0.23
98-
node --version
99-
v20.10.0
100-
hyperfine 1.18.0
101-
102-
===== Running Benchmark =====
103-
104-
Summary
105-
lua bin-calculation.lua ran
106-
4.09 ± 0.52 times faster than nickel export bin-calculation.ncl
107-
4.70 ± 0.54 times faster than bun run bin-calculation.ts
108-
4.93 ± 0.75 times faster than bun run bin-calculation.js
109-
8.36 ± 1.00 times faster than python3 bin-calculation.py
110-
8.83 ± 1.21 times faster than deno run bin-calculation.js
111-
8.85 ± 1.05 times faster than deno run bin-calculation.ts
112-
11.39 ± 1.33 times faster than node bin-calculation.js
117+
./luajit ran
118+
1.06 ± 0.22 times faster than ./lua
119+
1.61 ± 0.27 times faster than ./bash
120+
1.62 ± 0.29 times faster than ./dash
121+
2.12 ± 0.49 times faster than ./ksh
122+
2.66 ± 0.55 times faster than ./osh
123+
3.77 ± 0.63 times faster than ./elvish
124+
3.91 ± 0.67 times faster than ./v.vsh
125+
4.92 ± 0.82 times faster than ./fish
126+
6.16 ± 1.02 times faster than ./bun
127+
9.65 ± 1.72 times faster than ./guile
128+
13.94 ± 2.29 times faster than ./python
129+
14.20 ± 2.39 times faster than ./nushell
130+
17.43 ± 2.86 times faster than ./php
131+
23.01 ± 3.94 times faster than ./ocaml
132+
35.43 ± 5.99 times faster than ./ruby
133+
52.94 ± 9.08 times faster than ./racket
134+
56.77 ± 9.59 times faster than ./perl
135+
89.13 ± 14.62 times faster than ./dart
136+
106.23 ± 18.77 times faster than ./swift
137+
143.96 ± 24.03 times faster than ./julia
138+
199.84 ± 33.40 times faster than ./roc.roc
139+
224.83 ± 47.56 times faster than ./elixir
140+
483.43 ± 87.95 times faster than ./haskell
141+
507.16 ± 114.14 times faster than ./scala
142+
528.19 ± 94.47 times faster than ./fsharp.fsx
113143
```
114144

115145

116146
## Related
117147

118148
- [jinyus/related_post_gen] - Data Processing benchmark
149+
- [plb2] - A programming language benchmark
150+
- [Programming-Language-Benchmarks][PLB]
119151
- [script-bench-rs] - Rust embedded scripting languages benchmark
120152

121153
[jinyus/related_post_gen]: https://github.com/jinyus/related_post_gen
154+
[PLB]: https://github.com/hanabi1224/Programming-Language-Benchmarks
155+
[plb2]: https://github.com/attractivechaos/plb2
122156
[script-bench-rs]: https://github.com/khvzak/script-bench-rs

Diff for: shebang-scripts/generate-chart.ts

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#! /usr/bin/env bun
2+
3+
import fs from "fs"
4+
import path from "path"
5+
import vega from "vega"
6+
import vl from "vega-lite"
7+
8+
// Load data from the JSON file
9+
const data = JSON.parse(
10+
fs.readFileSync(path.join(__dirname, "/today/result.json"), "utf8"),
11+
)
12+
13+
// Extract data from the JSON
14+
const results: { command: string; mean_time: number }[] = data.results.map(
15+
(result) => {
16+
return {
17+
command: result.command.replace("./", ""),
18+
mean_time: result.mean,
19+
}
20+
},
21+
)
22+
23+
console.log({ results })
24+
25+
// Convert results to a DataFrame-like structure
26+
const df = results.map((result, index) => ({
27+
...result,
28+
relative_speed: 0, // Placeholder for now
29+
}))
30+
31+
// Find the fastest entry (smallest mean_time)
32+
const fastestEntry = df.reduce((min, entry) => {
33+
return entry.mean_time < min.mean_time ? entry : min
34+
}, df[0])
35+
36+
const fastestCommand = fastestEntry.command
37+
const fastestTime: number = fastestEntry.mean_time
38+
39+
// Calculate times faster relative to the fastest entry
40+
df.forEach((entry) => {
41+
entry.relative_speed = fastestTime / entry.mean_time
42+
})
43+
44+
// Sort the DataFrame by relative_speed
45+
df.sort((a, b) => b.relative_speed - a.relative_speed)
46+
47+
console.log(df)
48+
49+
// Define the Vega-Lite chart specification
50+
const spec = {
51+
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
52+
title: `Relative Execution Speed (Higher is Better)`,
53+
mark: "bar",
54+
width: 800,
55+
height: 600,
56+
encoding: {
57+
x: {
58+
field: "command",
59+
type: "nominal",
60+
sort: "-y",
61+
title: "Command",
62+
axis: {
63+
labelAngle: -45,
64+
}
65+
},
66+
y: {
67+
field: "relative_speed",
68+
type: "quantitative",
69+
title: `Relative Speed in Comparison to ${fastestCommand}`,
70+
},
71+
tooltip: [{ field: "command" }, { field: "relative_speed" }],
72+
},
73+
data: {
74+
values: df,
75+
},
76+
}
77+
78+
// Create a Vega view for rendering
79+
const runtime = vl.compile(spec).spec
80+
const view = new vega.View(vega.parse(runtime), { renderer: "none" })
81+
82+
// Export to SVG
83+
view.toSVG().then((svg) => {
84+
fs.writeFileSync(path.join(__dirname, "today/chart.svg"), svg)
85+
console.log("Chart generated successfully!")
86+
})

Diff for: shebang-scripts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "dependencies": { "vega": "^5.30.0", "vega-canvas": "^1.2.7", "vega-lite": "^5.20.1" } }

Diff for: shebang-scripts/today/_all_.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
./bash
2+
./bun
3+
./dart
4+
./dash
5+
./elixir
6+
./elvish
7+
./fish
8+
./fsharp.fsx
9+
./guile
10+
./haskell
11+
./janet
12+
./julia
13+
./ksh
14+
./lua
15+
./luajit
16+
./nushell
17+
./ocaml
18+
./osh
19+
./perl
20+
./php
21+
./python
22+
./racket
23+
./rust-script
24+
./roc.roc
25+
./ruby
26+
./scala
27+
./swift
28+
./v.vsh

Diff for: shebang-scripts/today/chart.svg

+1
Loading

0 commit comments

Comments
 (0)