Skip to content

Commit 751730e

Browse files
committed
bench: update benchmark results
1 parent c310aa3 commit 751730e

1 file changed

Lines changed: 100 additions & 11 deletions

File tree

‎bench/README.md‎

Lines changed: 100 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,104 @@
1-
### Vectors
1+
# V Benchmarks
22

3-
```bash
4-
Benchmark 1: ./boids_test/bin/Release/net7.0/linux-x64/publish/boids_test
5-
Time (mean ± σ): 262.2 ms ± 5.7 ms [User: 231.6 ms, System: 14.1 ms]
6-
Range (min … max): 255.4 ms … 275.3 ms 11 runs
3+
All benchmarks compiled with `v -prod` on Apple M5, 16 GB RAM, macOS (arm64).
4+
V version: 0.5.1.
75

8-
Benchmark 2: ./vinted_report_generator/main
9-
Time (mean ± σ): 208.3 ms ± 1.9 ms [User: 205.4 ms, System: 1.6 ms]
10-
Range (min … max): 204.9 ms … 210.6 ms 14 runs
6+
## GC: Boehm vs VGC
117

12-
Summary
13-
./vinted_report_generator/main ran
14-
1.26 ± 0.03 times faster than ./boids_test/bin/Release/net7.0/linux-x64/publish/boids_test
8+
Compares Boehm GC (`-gc boehm`) against V's built-in concurrent tri-color mark-and-sweep (`-gc vgc`).
9+
5 iterations per test, median reported.
10+
11+
```
12+
v run bench/bench_gc.v
13+
```
14+
15+
```
16+
test boehm vgc ratio
17+
———————————————————————————————————————————— ————————— ————————— —————————
18+
small allocs (1000000x string) 41 ms 59 ms 1.44x
19+
tree build+walk (depth=18, 10x) 49 ms 156 ms 3.18x
20+
array grow (100x 100000 pushes) 8 ms 33 ms 4.13x
21+
map insert (20x 10k entries) 20 ms 31 ms 1.55x
22+
mixed workload (50 rounds) 10 ms 21 ms 2.10x
23+
24+
heap usage:
25+
boehm: 29856 KB allocated, 29312 KB free
26+
vgc: 131072 KB allocated, 0 KB free
27+
```
28+
29+
Boehm is 1.4x-4x faster across all workloads and uses ~4x less heap.
30+
31+
## Closures
32+
33+
Measures closure creation, invocation, multi-threaded creation, and memory overhead.
34+
35+
```
36+
v -prod -o /tmp/bench_closure bench/bench_closure.v && /tmp/bench_closure
37+
```
38+
39+
```
40+
| Test Name | Iterations | Time(ms) | Ops/sec |
41+
|---------------------------|------------|----------|--------------|
42+
| Normal Function Call | 100000000 | 0 | +inf Mop/s |
43+
| Small Closure Creation | 10000000 | 188 | 53.19 Mop/s |
44+
| Medium Closure Creation | 10000000 | 376 | 26.60 Mop/s |
45+
| Large Closure Creation | 1000000 | 121 | 8.26 Mop/s |
46+
| Small Closure Call | 100000000 | 136 | 735.29 Mop/s |
47+
| Medium Closure Call | 100000000 | 133 | 751.88 Mop/s |
48+
| Large Closure Call | 10000000 | 16 | 625.00 Mop/s |
49+
| Multi-threaded Creation | 1000000 | 95 | 10.53 Mop/s |
50+
```
51+
52+
Memory: ~69 bytes per closure (medium, 4 captured vars). Closure calls are ~625-750 Mop/s.
53+
54+
## String Deduplication
55+
56+
Compares four deduplication strategies on 10,000 strings with ~30% duplicates.
57+
58+
```
59+
v -prod -o /tmp/bench_string_dedup bench/bench_string_dedup.v && /tmp/bench_string_dedup
60+
```
61+
62+
```
63+
Method 1 (basic array) 33 ms 7000 unique
64+
Method 2 (pre-allocated array) 27 ms 7000 unique
65+
Method 3 (map) 0 ms 7000 unique
66+
Method 4 (set) 0 ms 7000 unique
67+
```
68+
69+
Maps and sets are orders of magnitude faster than linear array search for deduplication.
70+
71+
## Vectors (Boids Simulation)
72+
73+
N-body boids simulation with 10,000 entities: cohesion, separation, and alignment.
74+
75+
```
76+
v -prod -o /tmp/bench_vectors bench/vectors/vectors.v && /tmp/bench_vectors
77+
```
78+
79+
```
80+
~50 ms per run (after warmup)
81+
```
82+
83+
## Crypto: ECDSA
84+
85+
Key generation, signing, and verification (1,000 iterations each).
86+
87+
```
88+
v -prod -o /tmp/bench_ecdsa bench/crypto/ecdsa/ecdsa.v && /tmp/bench_ecdsa
89+
```
90+
91+
```
92+
Average key generation time: 9 µs
93+
Average sign time: 11 µs
94+
Average verify time: 30 µs
95+
```
96+
97+
## SOA Structs
98+
99+
`bench_soa_structs.v` compares Array-of-Structs vs Struct-of-Arrays layout for a 16-field
100+
particle system (500k particles). Requires `@[soa]` attribute support.
101+
102+
```
103+
v -prod -o /tmp/bench_soa bench/bench_soa_structs.v && /tmp/bench_soa
15104
```

0 commit comments

Comments
 (0)