Haskell Benchmarks Show Root-Based Trees Beat Zippers Except for Local Edits
A performance comparison between zipper and root-based tree traversal in Haskell was conducted across three tree shapes containing over one million leaves each, with 100,000 operations per benchmark. The tests covered random lookups, random edits, and local edits on trees of varying depth and width. Root-based traversal outperformed zippers significantly on random lookups, running up to 4x faster, and also led on random edits by 1.3x to 1.7x. However, zippers gained a clear advantage in local edit workloads, where repeated nearby modifications allowed them to outperform the root-based approach by up to 3.3x on deeper, narrower trees. The benchmarks were run on an Apple M4 MacBook Air using GHC 9.10.3 compiled with -O2 optimisation.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in