Skip to content

What an instruction costs

A processor has no «expensive» and «cheap» lines: it counts them by the piece, and the pieces per tick are exactly @ipt

tick 0
Operation0
=
Set1
=
Operation2
=
@counter0number
loopsnullnull
speednullnull
loopsPerTicknullnull

A hyper processor, a program of three lines. Look at loopsPerTick: about 8.3 — that is twenty-five instructions a tick divided by the three lines of an iteration.

All the arithmetic of speed comes out of that:

What Formula
instructions per tick @ipt: 2, 8 or 25
iterations per tick @ipt ÷ the length of the program
iterations per second the same, times 60

op add and radar enemy any any distance duo1 1 aim are one instruction each. The processor does not count how much work stands behind a line; it counts lines.

That does not mean the cost is truly identical: radar walks the units internally, and on a big map it costs the game more than an addition. But it makes no difference at all to the speed of your program — exactly @ipt lines will pass in a tick regardless.

What Does it cost
a comment in the block editor no: it is not an instruction
a label no: it does not get into the program
end at the end of a program no: the end is handled anyway
an empty line, noop one instruction
a jump that did not fire one instruction

The last one matters more than it seems: checks that are almost always false cost as much as the ones that fire. A program of twenty “has it happened yet” checks spends twenty instructions on them every iteration — and if one of them is expensive in meaning, it is better checked once a second by a deadline than every time.

Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.