# The instructions that each case retires for each step of `N` on macOS on Apple silicon, the only platform with these counts. `tests/test_instructions.py` checks them with `basedpl.bpltests.instruction_budgets`.
# Instruction counts don't change with load or code layout. The cases that make one call per step repeat within about 0.2%, and those that map over 64 cells within about 1%. They show changes of a few percent per call or per cell, which costs in copies can't.
# A case fails when it retires more than 3% more, or more than 3% fewer, instructions than its count. The change that makes a call cheaper also lowers each count it moves. A new compiler version can inline differently and move the counts. After one, set them again from `bpl-tests instruction_budgets`.
[setup]
fib←{⍵<2ₓ?⍵;(∇⍵-1ₓ)+∇⍵-2ₓ} ⋄ g←{⍵<2ₓ?⍵;(g ⍵-1ₓ)+g ⍵-2ₓ} ⋄ k←0 ⋄ t←64⍴"ab" "cde" ⋄ m←[0 1⋄¯1 0] ⋄ s←[64 2 2]⍴$t $f $f $t $t $t $f $t ⋄ v_4←1.5 2.5 3.5 4.5
[calls]
# A primitive call.
+⍣N 0	395
# A dfn call that returns its argument.
{⍵}⍣N 0	1452
# A dfn that reads a global.
{⍵+k}⍣N 0	2593
# A local assignment and read.
{x←⍵+1 ⋄ x}⍣N 0	3003
# A spaced run that builds a train and applies it at once.
{(⍵)+⊢ ⍵}⍣N 0	4309
# A bracket literal. It counted 5,620 on 24 October 2026. Joining its items' kinds, fixedness and weakness in `Promoted::join` added about 125 instructions. The memory guard's check on each allocation and the later promotion refactor added about 95 more.
{↑[⍵ 1]}⍣N 0	5841
# A fixed mark on a 4-item float vector, which floors each item to `i32` through `derivative::converted`, the entry point that marks on values and on functions share. Stage 3's step 6 sent value marks there, which cost about 215 instructions. The inline size test in `fusion::convert` and the inline tests of `Value::carried` and `Value::holds_values` recover about 100 of them. On 26 October 2026, single-stepping `binder::derived` under lldb counted every instruction that it and its calls retire. Outside `malloc`, the other 115 lay in four functions: 130 in `derivative::converted`, 17 in an out-of-line `product` for its size test's length, 15 in `Value::converted`'s dispatch, and 47 fewer in `binder::derived`, which no longer reads the settings itself. Of the 130, about 45 read the settings, 25 test for carriers and 12 make the size test. The inline `rustymath::layout::count` and an always-inlined `derivative::plain` then saved 19.
v_4ₓ₄	3825
# `fib 10ₓ` makes 177 calls, which read `⍵` and `∇`.
{fib 10ₓ}⍣N 0	824136
# `g 10ₓ` makes 177 calls of a dfn that calls itself by name, with spaces that split its statement into runs.
{g 10ₓ}⍣N 0	978171
# `fib 10ₓ` under static kinds, whose integer scalar calls run their integer kernel at the `int` width (`Primitive::integer_kernel`).
•prefs ["kinds":"static"] ⋄ {fib 10ₓ}⍣N 0	870789
# Each over a nested vector, which can't batch, calls `⌽` once for each of the 64 strings in `t`. It counted 290,267 on 25 October 2026. Later that day a longer zero-axis scan in rustymath's `element_count` and stage 3's single map type, where `remap` builds a `Mapping` that `copying` reads back, made each string's reversed copy about 150 instructions dearer. Other changes recovered that rise, among them scanning only where a shape's product overflows, inlining `Mapping::from` and `Mapping::to_walk`, and the inline tests in `Value::carried`. On 26 October 2026, with this file's setup, the 02:01 build of 25 October counted 290,445 and a build of 26 October 291,153. Reading each part once in `plan::Kind::join`, which joins each copy's kind, then saved about 8,700. Later that day it rose to about 290,400, from `Route`'s drop and the fill option's pass through `Mapping::filled`. On 27 October 2026 four changes brought it to 278,025, about 180 instructions fewer for each string: `Mapping::filled` returns a mapping that keeps no fill without moving it, `plan::Kind::value` asks only integer arrays for a fixed width, `Kind::join` returns a lone part as it is, and `Storage::dtype` reads the buffer's dtype with no view. The count moves by up to about 2,400 with the setup alone.
⌽¨⍣N t	261119
# Rank's general path calls a dfn once for each of the same 64 cells.
{⌽⍵}⍤0⍣N t	316700
# A system function maps itself over the same 64 cells.
•ucs⍣N t	202400
# A 2×2 float matrix product.
{m+.×m}⍣N 0	6500
# Rank on a stack of 64 Boolean 2×2 matrices, which runs one or-and product for the whole stack.
{∨.∧⍤2⍨s}⍣N 0	27500
