Improved assembler performance

This commit is contained in:
2025-03-11 06:31:21 +01:00
parent d2ad8c8310
commit e7a06f5b26
37 changed files with 412 additions and 166 deletions

36
src/asm/bench_test.go Normal file
View File

@ -0,0 +1,36 @@
package asm_test
import (
"testing"
"git.urbach.dev/cli/q/src/asm"
)
func BenchmarkMerge(b *testing.B) {
n := 100
all := make([]*asm.Assembler, 0, n)
for range n {
f := &asm.Assembler{}
f.Number(asm.PUSH, 1)
f.Number(asm.PUSH, 2)
f.Number(asm.PUSH, 3)
all = append(all, f)
}
for b.Loop() {
final := asm.Assembler{}
for _, f := range all {
final.Merge(f)
}
}
}
func BenchmarkNumber(b *testing.B) {
a := asm.Assembler{}
for b.Loop() {
a.Number(asm.PUSH, 42)
}
}