diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-30 18:45:11 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-30 18:50:19 -0700 |
| commit | aa8a935f620a053cc9c3c65587b433f3e8d3a6e9 (patch) | |
| tree | a786b3174c1a901f19fc10485c4856d60ef93d6b /ccl_test.go | |
| parent | Don't allocate an intermediate map[string]any (diff) | |
| download | ccl-aa8a935f620a053cc9c3c65587b433f3e8d3a6e9.tar.zst | |
Use a classic struct iterator instead of iter.Pull
iter.Pull doesn't provide much value here. Actually the lexer is
probably simpler this way, and iter.Pull also destroys stack traces for
panics in the lexer.
Ouch
goos: linux
goarch: amd64
pkg: roseh.moe/pkg/ccl
cpu: AMD Ryzen 9 5900X 12-Core Processor
│ baseline.txt │ itern't.txt │
│ sec/op │ sec/op vs base │
Lex-24 1.436µ ± 0% 1.320µ ± 0% -8.05% (p=0.000 n=20)
Parse-24 7.846µ ± 0% 4.801µ ± 0% -38.82% (p=0.000 n=20)
geomean 3.356µ 2.517µ -24.99%
Diffstat (limited to 'ccl_test.go')
| -rw-r--r-- | ccl_test.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ccl_test.go b/ccl_test.go index ab4833f..53b2a24 100644 --- a/ccl_test.go +++ b/ccl_test.go @@ -684,8 +684,13 @@ func BenchmarkLex(b *testing.B) { repeated: [5, 6] `) for b.Loop() { - for _, err := range tokens(msg) { + l := newLexer(msg) + for { + _, err := l.next() if err != nil { + if err == errEOF { + break + } b.Fatal(err) } } |
