-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark.sh
More file actions
executable file
·76 lines (62 loc) · 1.5 KB
/
Copy pathbenchmark.sh
File metadata and controls
executable file
·76 lines (62 loc) · 1.5 KB
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
#!/usr/bin/env bash
set -euo pipefail
# --- Configuration ---
# 10 MILLION ITERATIONS
N=10000000
# --- Build Step ---
echo "Building AbyssLang..."
make
# --- Generate AbyssLang Source ---
echo "Generating sample.al with N=${N}..."
cat > sample.al <<AL
void main() {
print("AbyssLang benchmark start");
int i = 0;
int N = ${N};
while (i < N) {
print(42);
i = i + 1;
}
print("AbyssLang benchmark end");
}
AL
# --- Compile AbyssLang Source ---
echo "Compiling sample.al..."
./abyssc sample.al sample.aby
# --- Generate Equivalent Python Test Script ---
echo "Generating Python test script..."
cat > test.py <<PY
import sys
import time
def main():
w = sys.stdout.write
N = ${N}
w("Python benchmark start\n")
for i in range(N):
w("42\n")
w("Python benchmark end\n")
if __name__ == "__main__":
main()
PY
# --- Run Performance Timings ---
echo
echo "======================================================="
echo " THE BATTLE OF 10 MILLION ITERATIONS"
echo "======================================================="
echo
echo "--- AbyssLang (VM) Performance ---"
# We use /usr/bin/time -v to get detailed stats including memory
if [ -f /usr/bin/time ]; then
/usr/bin/time -v ./abyss_vm sample.aby > /dev/null
else
time ./abyss_vm sample.aby > /dev/null
fi
echo
echo "--- Python 3 Performance ---"
if [ -f /usr/bin/time ]; then
/usr/bin/time -v python3 test.py > /dev/null
else
time python3 test.py > /dev/null
fi
echo
echo "Benchmark complete."