Commit 3bd5f244
3bd5f244e390Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 2 files · +1 added · ~1 modified
Description
feat: add bm_huffman benchmark
Huffman encoding on a generated 200 K-byte text:
- byte-frequency counting via int-indexed table
- priority-queue (linear-min) tree construction
- per-byte code assignment via DFS walk
- total encoded bit length as the output
Exercises nullable self-referential objects (the Huffman tree), int-indexed arrays as lookup tables, and recursive tree walks.
Spinel 10 ms vs Ruby 200 ms (~20x).
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 3bd5f244e390
- Parent
- 90f9c86cb2c7
README.mdmodifiedView file
@@ -78,7 +78,7 @@
7878
7979
## Benchmarks8080
81-
74 tests pass. 54 benchmarks pass.81+
74 tests pass. 55 benchmarks pass.8282
Geometric mean: **~49x faster** than CRuby across 50 benchmarks.8383
8484
### Computation@@ -104,6 +104,7 @@
104104
| Benchmark | Spinel | CRuby | Speedup |105105
|---|---|---|---|106106
| rbtree (red-black tree) | 23 ms | 571 ms | 24.8x |107+
| huffman (encoding) | 10 ms | 200 ms | 20.0x |107108
| splay tree | 14 ms | 241 ms | 17.2x |108109
| binary_trees | 11 ms | 105 ms | 9.5x |109110
| so_lists | 74 ms | 510 ms | 6.9x |@@ -230,7 +231,7 @@
230231
lib/sp_bigint.c Arbitrary precision integers (5,394 lines)231232
lib/regexp/ Built-in regexp engine (1,626 lines)232233
test/ 74 feature tests233-
benchmark/ 54 benchmarks234+
benchmark/ 55 benchmarks234235
Makefile Build automation235236
```236237
@@ -259,7 +260,7 @@
259260
```bash260261
make # build parser + regexp library + bootstrap compiler261262
make test # run 74 feature tests (requires bootstrap)262-
make bench # run 54 benchmarks (requires bootstrap)263+
make bench # run 55 benchmarks (requires bootstrap)263264
make bootstrap # rebuild compiler from source264265
sudo make install # install to /usr/local (spinel in PATH)265266
make clean # remove build artifactsbenchmark/bm_huffman.rbaddedView file
Loading diff…