# 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]⍴1 0 0 1 1 1 0 1=1
[calls]
# A primitive call.
+⍣N⊢0	482
# A dfn call that returns its argument.
{⍵}⍣N⊢0	1636
# A dfn that reads a global.
{⍵+k}⍣N⊢0	2933
# A local assignment and read.
{x←⍵+1 ⋄ x}⍣N⊢0	3555
# A spaced run that builds a train and applies it at once.
{(⍵)+⊢ ⍵}⍣N⊢0	5558
# A bracket literal.
{↑[⍵ 1]}⍣N⊢0	6453
# `fib 10` makes 177 calls, which read `⍵` and `∇`.
{fib 10}⍣N⊢0	965100
# `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	1205600
# Each over a nested vector, which can't batch, calls `⌽` once for each of the 64 strings in `t`.
⌽¨⍣N⊢t	350800
# Rank's general path calls a dfn once for each of the same 64 cells.
{⌽⍵}⍤0⍣N⊢t	364700
# A system function maps itself over the same 64 cells.
•ucs⍣N⊢t	229500
# A 2×2 float matrix product.
{m+.×m}⍣N⊢0	8550
# Rank on a stack of 64 Boolean 2×2 matrices, which runs one or-and product for the whole stack.
{∨.∧⍤2⍨s}⍣N⊢0	99000
