-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·93 lines (79 loc) · 1.95 KB
/
test.sh
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
#!/bin/bash
# Create bin directory if it doesn't exist
mkdir -p ./bin
# # Create Matrix pre-benchmark
# echo "Creating Matrix pre-benchmark..."
# python3 ./create_matrix.py
# mv matrix_size.txt ./bin/
# mv ./*.bin ./bin/
# Compile Go
echo "Compiling Go..."
cd ./go/
go build -o ../bin/go_bin main.go
cd ..
# Compile C#
echo "Compiling C#..."
cd ./csharp/
dotnet publish -c Release -o ./csharp_out
mv ./csharp_out/csharp ../bin/csharp_bin
cd ..
# Compile F#
# echo "Compiling F#..."
# cd ./fsharp/
# dotnet build -c Release
# cd ..
# Compile Rust
echo "Compiling Rust..."
cd rust/matrix
RUSTFLAGS="-C target-cpu=native" cargo build --release
mv ./target/release/matrix ../../bin/rust_bin
cd ../..
# Compile zig
echo "Compiling zig..."
cd zig/
zig build -Doptimize=ReleaseFast
cd ..
mv ./zig/zig-out/bin/zig ./bin/zig_bin
# Compile TS with Bun
echo "Compiling TS with Bun..."
cd ts/
bun build ./index.ts --compile --outfile ts_bin
cd ..
mv ./ts/ts_bin ./bin/ts_bin
# Compile C++ Clang
echo "Compiling C++..."
cd cpp/
clang++ -std=c++17 -Ofast -mtune=native -Wall -Wextra -pedantic -o ../bin/cpp_bin_clang main.cc
cd ..
# Compile C++ GCC
echo "Compiling C++..."
cd cpp/
g++ -std=c++20 -Ofast -mtune=native -Wall -Wextra -pedantic -o ../bin/cpp_bin_gcc main.cc
cd ..
# Swift
echo "Compiling Swift..."
cd swift/
swiftc -O -whole-module-optimization matrix.swift -o matrix_swift
cd ..
mv ./swift/matrix_swift ./bin/swift_bin
# Java
echo "Compiling Java..."
cd java/
./gradlew jar
cd ..
mv ./java/app/build/libs/app.jar ./bin/java_bin.jar
# Run benchmarks
echo "Running benchmarks..."
cd bin
hyperfine --warmup 0 --runs 4 --show-output --export-markdown ../benchmark_results.md \
'./go_bin' \
'./csharp_bin' \
'./rust_bin' \
'./zig_bin' \
'./cpp_bin_gcc' \
'./cpp_bin_clang' \
'dotnet run --project ../csharp/csharp.csproj -c Release' \
'./ts_bin' \
'./swift_bin' \
'java -jar java_bin.jar'
# 'python3 ../python/main.py' \ # waaaay to slow