Performance
build-stubbed exists specifically to avoid the database; that advantage
should be real and stay real across releases.
Guarantees
build-stubbedmakes zeropersist()calls. The adapter sees oneinstantiateand onestub, and nopersist. This is asserted byspecs/factory/performance-spec.raku, so accidentally routingbuild-stubbedthroughpersistwill fail CI.buildmakes zeropersist()calls. Same idea —buildis the no-save sibling ofcreateand that contract is asserted.attributes-formakes zero adapter calls. It returns the resolved attribute hash without ever touchinginstantiate,persist, orstub.- Evaluator memoisation. Each attribute (transient or persisted) is computed at most once per build, even when referenced from multiple callbacks or dependent attributes.
The benchmark harness
bin/bench runs each of the four strategies against the same factory and
prints average wall-clock time per record. Default is 1000 records, 3
repeats:
1 2 3 4 5 6 7 | |
Use --count and --repeat to scale the workload:
1 | |
The harness uses the in-memory generic adapter (no DB), so the difference
between create and the others reflects only the save-bang call cost.
Regression guard
The performance spec includes a coarse guard: build-stubbed-list is asserted
to be no more than 2× slower than create-list over 200 records. That gap
catches order-of-magnitude regressions without flaking on machine noise. For
finer regression tracking, run bin/bench before and after a change.