Make threshold parameterizable, to allow benchmarking.