Fail Faster: Staging and Fast Randomness for High-Performance PBT
Open Access
- 10 April 2026
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
- Vol. 10 (OOPSLA1) , 1737-1762
Abstract
Property-based testing (PBT) relies on generators for random test cases, often constructed using embedded domain specific languages, which provide expressive combinators for building and composing generators. The effectiveness of PBT depends critically on the speed of these generators. However, careful measurements show that the generator performance of widely used PBT libraries falls well short of what is possible, due principally to (1) the abstraction overhead of their combinator-heavy style and (2) suboptimal sources of randomness. We characterize, quantify, and address these bottlenecks. To eliminate abstraction overheads, we propose a technique based on multi-stage programming, dubbed Allegro. We apply this technique to leading generator libraries in OCaml and Scala 3, significantly improving performance. To quantify the performance impact of the randomness source, we carry out a controlled experiment, replacing the randomness in the OCaml PBT library with an optimized version. Both interventions exactly preserve the semantics of generators, enabling precise, pointwise comparisons. Together, these improvements find bugs up to 13× faster.Keywords
All Related Versions
This publication has 44 references indexed in Scilit:
- Generating constrained random data with uniform distributionJournal of Functional Programming, 2015
- Type Targeted Testing2015
- Creating languages in RacketCommunications of the ACM, 2012
- Languages as libraries2011
- Mint2010
- Domain specific language implementation via compile-time meta-programmingACM Transactions on Programming Languages and Systems, 2008
- Smallcheck and lazy smallcheckACM SIGPLAN Notices, 2008
- Contextual modal type theoryACM Transactions on Computational Logic, 2008
- A short cut to deforestation1993
- Improving binding times without explicit CPS-conversion1992