We currently support reporting the number of opcodes on each line of Noir source, however a more useful metric is the number of constraints which these opcodes will generate. This is nontrivial as:
- constraint counts vary by backend
- certain opcodes have associated fixed costs which are shared between all others of that type.
It's then not possible to give an exact count, what we can do instead is allow an inexact estimation of the opcode->constraint conversion, i.e.:
- Extension settings allows setting a weight for each opcode e.g.
AssertZero == 1, Keccak256== 20000.
- Reasonable defaults are provided for barretenberg which provides a reasonable estimation of the number of constraints each opcode produces.