← All data structures

Radix tree benchmark

C# (340ms)
Rust (349ms)
C++ (355ms)
Swift (358ms)
C (363ms)
Go (380ms)
Zig (393ms)
Bun (464ms)
Java (534ms)
Node.js (659ms)
Python (4,044ms)

Times are the geometric mean of the language's median times over the 10 tests.

In-memory radix tree (a path-compressed trie) mapping byte-string keys to i64 values, with longest-prefix match, prefix counts and ordered prefix listings. Every implementation on this page was written by an AI model from the same prompt, then tested and timed by the same harness.

Results: claude-opus-5-5_high

Median time per case (ms)

CaseCC++RustGoZigSwiftJavaC#Node.jsBunPython
Insert, random4531.15×4601.17×4991.27×5691.45×5071.29×5141.31×6341.61×3931.00×6291.60×4891.24×4,34811.06×
Get, present3881.03×4011.06×3881.03×3831.01×3851.02×3771.00×5271.40×3821.01×7111.89×5671.50×2,7757.36×
Get, near misses2171.04×2261.08×2161.03×2351.12×2461.17×2261.08×3801.81×2101.00×4312.05×2751.31×2,40911.48×
Longest prefix2381.12×2461.16×2521.18×2681.26×2631.24×2341.10×4191.97×2131.00×4502.12×3281.55×2,79613.16×
Prefix count3151.00×3171.01×3651.16×3471.10×4021.28×3491.11×4411.40×3331.06×5791.84×3641.15×3,39510.78×
Autocomplete3821.25×3611.19×3041.00×3291.08×4211.38×3581.18×5711.88×3531.16×7382.43×4541.49×7,76225.52×
Scan subtrees4331.67×3281.26×2591.00×3951.52×3971.53×2851.10×7873.03×3741.44×1,2514.82×7592.93×9,67737.30×
Remove all4811.14×5051.19×5351.26×5651.33×5031.19×5021.18×6381.51×4241.00×6981.65×5411.28×3,4268.09×
Mixed4441.12×4211.06×3971.00×4181.05×4271.08×4391.11×5151.30×4051.02×6991.76×5721.44×3,1247.88×
Churn, small tree3981.04×3831.00×4141.08×4341.13×4791.25×4301.12×5381.41×4131.08×6871.80×4781.25×5,26813.77×
Overall (geometric mean)3631.07×3551.04×3491.02×3801.12×3931.15×3581.05×5341.57×3401.00×6591.94×4641.36×4,04411.88×

Median time per case, log scale (ms)

Insert, random
100 ms1 s10 sC#: median 393 ms (min 387, max 399; 2 samples)C#393 msC: median 453 ms (min 447, max 460; 2 samples)C453 msC++: median 460 ms (min 459, max 461; 2 samples)C++460 msBun: median 489 ms (min 480, max 498; 2 samples)Bun489 msRust: median 499 ms (min 493, max 504; 2 samples)Rust499 msZig: median 507 ms (min 507, max 508; 2 samples)Zig507 msSwift: median 514 ms (min 490, max 538; 2 samples)Swift514 msGo: median 569 ms (min 556, max 583; 2 samples)Go569 msNode.js: median 629 ms (min 628, max 630; 2 samples)Node.js629 msJava: median 634 ms (min 626, max 642; 2 samples)Java634 msPython: median 4,348 ms (min 4,340, max 4,357; 2 samples)Python4,348 ms
Get, present
100 ms1 s10 sSwift: median 377 ms (min 372, max 382; 2 samples)Swift377 msC#: median 382 ms (min 375, max 388; 2 samples)C#382 msGo: median 383 ms (min 382, max 383; 2 samples)Go383 msZig: median 385 ms (min 384, max 385; 2 samples)Zig385 msRust: median 388 ms (min 383, max 392; 2 samples)Rust388 msC: median 388 ms (min 380, max 397; 2 samples)C388 msC++: median 401 ms (min 396, max 405; 2 samples)C++401 msJava: median 527 ms (min 511, max 544; 2 samples)Java527 msBun: median 567 ms (min 541, max 592; 2 samples)Bun567 msNode.js: median 711 ms (min 706, max 715; 2 samples)Node.js711 msPython: median 2,775 ms (min 2,761, max 2,789; 2 samples)Python2,775 ms
Get, near misses
100 ms1 s10 sC#: median 210 ms (min 206, max 214; 2 samples)C#210 msRust: median 216 ms (min 216, max 217; 2 samples)Rust216 msC: median 217 ms (min 215, max 220; 2 samples)C217 msSwift: median 226 ms (min 225, max 227; 2 samples)Swift226 msC++: median 226 ms (min 225, max 228; 2 samples)C++226 msGo: median 235 ms (min 230, max 239; 2 samples)Go235 msZig: median 246 ms (min 242, max 250; 2 samples)Zig246 msBun: median 275 ms (min 275, max 276; 2 samples)Bun275 msJava: median 380 ms (min 367, max 394; 2 samples)Java380 msNode.js: median 431 ms (min 423, max 438; 2 samples)Node.js431 msPython: median 2,409 ms (min 2,381, max 2,437; 2 samples)Python2,409 ms
Longest prefix
100 ms1 s10 sC#: median 213 ms (min 210, max 215; 2 samples)C#213 msSwift: median 234 ms (min 231, max 238; 2 samples)Swift234 msC: median 238 ms (min 235, max 241; 2 samples)C238 msC++: median 246 ms (min 245, max 246; 2 samples)C++246 msRust: median 252 ms (min 251, max 252; 2 samples)Rust252 msZig: median 263 ms (min 260, max 265; 2 samples)Zig263 msGo: median 268 ms (min 265, max 272; 2 samples)Go268 msBun: median 328 ms (min 324, max 333; 2 samples)Bun328 msJava: median 419 ms (min 418, max 421; 2 samples)Java419 msNode.js: median 450 ms (min 438, max 461; 2 samples)Node.js450 msPython: median 2,796 ms (min 2,783, max 2,809; 2 samples)Python2,796 ms
Prefix count
100 ms1 s10 sC: median 315 ms (min 312, max 318; 2 samples)C315 msC++: median 317 ms (min 311, max 323; 2 samples)C++317 msC#: median 333 ms (min 331, max 335; 2 samples)C#333 msGo: median 347 ms (min 344, max 350; 2 samples)Go347 msSwift: median 349 ms (min 345, max 352; 2 samples)Swift349 msBun: median 364 ms (min 362, max 365; 2 samples)Bun364 msRust: median 365 ms (min 363, max 368; 2 samples)Rust365 msZig: median 402 ms (min 401, max 404; 2 samples)Zig402 msJava: median 441 ms (min 433, max 450; 2 samples)Java441 msNode.js: median 579 ms (min 576, max 582; 2 samples)Node.js579 msPython: median 3,395 ms (min 3,385, max 3,405; 2 samples)Python3,395 ms
Autocomplete
100 ms1 s10 sRust: median 304 ms (min 302, max 306; 2 samples)Rust304 msGo: median 329 ms (min 322, max 335; 2 samples)Go329 msC#: median 353 ms (min 351, max 355; 2 samples)C#353 msSwift: median 358 ms (min 356, max 361; 2 samples)Swift358 msC++: median 361 ms (min 360, max 363; 2 samples)C++361 msC: median 382 ms (min 378, max 385; 2 samples)C382 msZig: median 421 ms (min 414, max 427; 2 samples)Zig421 msBun: median 454 ms (min 447, max 462; 2 samples)Bun454 msJava: median 571 ms (min 566, max 576; 2 samples)Java571 msNode.js: median 738 ms (min 738, max 738; 2 samples)Node.js738 msPython: median 7,762 ms (min 7,738, max 7,785; 2 samples)Python7,762 ms
Scan subtrees
100 ms1 s10 sRust: median 259 ms (min 259, max 259; 2 samples)Rust259 msSwift: median 285 ms (min 284, max 285; 2 samples)Swift285 msC++: median 328 ms (min 326, max 329; 2 samples)C++328 msC#: median 374 ms (min 373, max 376; 2 samples)C#374 msGo: median 395 ms (min 395, max 396; 2 samples)Go395 msZig: median 397 ms (min 395, max 399; 2 samples)Zig397 msC: median 433 ms (min 431, max 434; 2 samples)C433 msBun: median 759 ms (min 745, max 772; 2 samples)Bun759 msJava: median 787 ms (min 784, max 789; 2 samples)Java787 msNode.js: median 1,251 ms (min 1,243, max 1,260; 2 samples)Node.js1,251 msPython: median 9,677 ms (min 9,666, max 9,687; 2 samples)Python9,677 ms
Remove all
100 ms1 s10 sC#: median 424 ms (min 421, max 426; 2 samples)C#424 msC: median 481 ms (min 479, max 484; 2 samples)C481 msSwift: median 502 ms (min 497, max 506; 2 samples)Swift502 msZig: median 503 ms (min 500, max 506; 2 samples)Zig503 msC++: median 505 ms (min 505, max 506; 2 samples)C++505 msRust: median 535 ms (min 532, max 537; 2 samples)Rust535 msBun: median 541 ms (min 539, max 544; 2 samples)Bun541 msGo: median 565 ms (min 562, max 567; 2 samples)Go565 msJava: median 638 ms (min 625, max 652; 2 samples)Java638 msNode.js: median 698 ms (min 696, max 700; 2 samples)Node.js698 msPython: median 3,426 ms (min 3,419, max 3,433; 2 samples)Python3,426 ms
Mixed
100 ms1 s10 sRust: median 397 ms (min 392, max 401; 2 samples)Rust397 msC#: median 405 ms (min 403, max 407; 2 samples)C#405 msGo: median 418 ms (min 417, max 419; 2 samples)Go418 msC++: median 421 ms (min 419, max 423; 2 samples)C++421 msZig: median 427 ms (min 426, max 429; 2 samples)Zig427 msSwift: median 439 ms (min 436, max 442; 2 samples)Swift439 msC: median 444 ms (min 441, max 446; 2 samples)C444 msJava: median 515 ms (min 509, max 522; 2 samples)Java515 msBun: median 572 ms (min 572, max 572; 2 samples)Bun572 msNode.js: median 699 ms (min 696, max 702; 2 samples)Node.js699 msPython: median 3,124 ms (min 3,113, max 3,136; 2 samples)Python3,124 ms
Churn, small tree
100 ms1 s10 sC++: median 383 ms (min 379, max 386; 2 samples)C++383 msC: median 398 ms (min 396, max 401; 2 samples)C398 msC#: median 413 ms (min 411, max 415; 2 samples)C#413 msRust: median 414 ms (min 414, max 414; 2 samples)Rust414 msSwift: median 430 ms (min 427, max 434; 2 samples)Swift430 msGo: median 434 ms (min 420, max 447; 2 samples)Go434 msBun: median 478 ms (min 475, max 481; 2 samples)Bun478 msZig: median 479 ms (min 478, max 481; 2 samples)Zig479 msJava: median 538 ms (min 515, max 561; 2 samples)Java538 msNode.js: median 687 ms (min 682, max 693; 2 samples)Node.js687 msPython: median 5,268 ms (min 5,265, max 5,272; 2 samples)Python5,268 ms

Generation details

LanguageModelEffortGeneratedTime to generateAgent turnsCostLinesTestsSourceToolchain
Cclaude-opus-5-5high2026-11-22 16:37 UTC-07:004m 04s7$1.03581passedradix.c radix.h · logApple clang version 21.0.0 (clang-2100.4.1.1)
C++claude-opus-5-5high2026-11-22 16:40 UTC-07:004m 54s7$1.16707passedradix.cpp radix.hpp · logApple clang version 21.0.0 (clang-2100.4.1.1)
Rustclaude-opus-5-5high2026-11-22 16:35 UTC-07:005m 37s6$1.32808passedradix.rs · logrustc 1.100.0 (0ef1bc386 2026-11-09) (Homebrew)
Goclaude-opus-5-5high2026-11-22 16:33 UTC-07:006m 39s5$1.45799passedradix.go · loggo version go1.27.4 darwin/arm64
Zigclaude-opus-5-5high2026-11-22 16:58 UTC-07:005m 00s10$1.21553passedradix.zig · logzig 0.17.1
Swiftclaude-opus-5-5high2026-11-22 16:27 UTC-07:006m 26s12$1.53658passedRadixTree.swift · logApple Swift version 6.4.2 (swiftlang-6.4.2.1.9 clang-2100.4.1.1)
Javaclaude-opus-5-5high2026-11-22 16:31 UTC-07:005m 47s6$1.31584passedRadixTree.java · logopenjdk version "27.0.1.1" 2026-11-17
C#claude-opus-5-5high2026-11-22 16:26 UTC-07:005m 06s8$1.16520passedRadixTree.cs · logdotnet 11.0.100
Node.jsclaude-opus-5-5high2026-11-22 16:47 UTC-07:005m 22s9$1.14516passedradix.mjs · lognode v26.13.1
Bunclaude-opus-5-5high2026-11-22 16:47 UTC-07:005m 37s8$1.28598passedradix.mjs · logbun 1.4.5
Pythonclaude-opus-5-5high2026-11-22 16:25 UTC-07:002m 44s5$0.63293passedradix.py · logPython 3.15.2

Peak RSS per case (MB)

CaseCC++RustGoZigSwiftJavaC#Node.jsBunPython
Insert, random2271913176902272981,285361449588586
Get, present2081672573932052681,693359445818539
Get, near misses3082013594563093061,828426375746599
Longest prefix3142063654553153111,854429360812591
Prefix count2691953193732693011,792347360794574
Autocomplete2712093223812713011,794344375799578
Scan subtrees2081672573122052681,698337362806745
Remove all1961562941,0181942571,682320433703562
Mixed3572694015073494061,8925274731,061679
Churn, small tree7777781677777281163168296227

Test cases

CaseWhat is timed
Insert, randomn inserts: the n keys are inserted in random order into an empty tree, which splits edges as it grows.
Get, presentn lookups of keys that are present, in random order, on a tree of n keys.
Get, near missesn lookups of absent keys that share long prefixes with present ones (a present key with "/0" appended, with its last byte changed, or with another numeric tail), on a tree of n keys.
Longest prefixn longest-prefix queries on a tree of n keys, as a routing table is queried: present and absent keys, extended by digits, a path segment or binary bytes.
Prefix count4n counts (4 passes of n) of the keys that start with a prefix cut from a random key at a random length, so the answer ranges from one key to the whole tree.
Autocomplete2n prefix listings (2 passes of n) with a limit of 8: the values of the first 8 keys, in key order, that start with a prefix of a random key.
Scan subtrees8 passes that each read every value of 401 large subtrees in key order (the whole tree, its 16 first-level and 384 second-level subtrees): about 22n values from a tree of n keys.
Remove alln removes that take all n keys out of a tree in random order, merging nodes until the tree is empty.
Mixedn operations on a tree of about n keys, over a domain of 2n keys: 60% get, 10% longest prefix, 5% prefix count, 5% prefix listing (limit 4), 10% insert, 10% remove.
Churn, small tree3n inserts and removes (half each) of random keys from a domain of 32,768 on a tree of about 16,384 keys that stays inside the CPU caches, splitting and merging nodes all the time.

Method