#3180·Catch2

Clock resolution estimation iterations limit

Author: BenzinnosCreated Jul 21, 2026Updated Jul 21, 2026

Description Hello. I'm trying to run a benchmark on an embedded system. The system is qemu-system-arm -machine mps2-an386 with 16MB RAM. It works, but I'm facing the following issue: during the measure_environment process, specifically in estimate_clock_resolution, it consumes all my available RAM and throws the std::bad_alloc exception.

The problem is that estimate_clock_resolution is only limited by time. At the same time, this is a hard-coded clock_resolution_estimation_time limit of 500ms and this cannot be configured without modifying the source code. It may be worth adding a limit on the number of iterations or allowing it to be configured. Alternatively, it may be possible to configure the time limit.

I suggest adding the ability to limit the number of iterations or the time limit using command-line parameters, similar to --benchmark-warmup-time e.g. --benchmark-estimate-clock-time.

Additional context During the measure_environment process, the number of iterations reached 1'280'000, which resulted in the allocation of 1'280'000 std::vector<TimePoint<Clock>> type elements in std::vector<TimePoint<Clock>> times(points) and 1'280'001 double type elements in std::vector<double> deltas.

Image