all repos

clerk @ 2f348cb

missing tooling for ledger/hledger

clerk/internal/lsp/diagnostics_test.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
test: lsp: align test naming, benchmark warm-up, and helper typo..., 1 month ago
1
package lsp
2
3
import (
4
	"testing"
5
6
	"olexsmir.xyz/clerk/internal/analyzer"
7
	"olexsmir.xyz/clerk/journal"
8
)
9
10
func BenchmarkDiagnostics(b *testing.B) {
11
	content := openJournal(b, "../../journal/testdata/journals/actual-1ktxns-100accts.journal")
12
	srv := NewServer("test")
13
14
	// Per-edit cost: a fresh loader skips the parse cache, so each iteration re-parses, then lints and groups findings.
15
	b.ReportAllocs()
16
	b.ResetTimer()
17
	for b.Loop() {
18
		an := analyzer.Build(journal.NewLoader().ResolveBytes("/test.journal", []byte(content)))
19
		finds := dedupFinds(srv.server.linter.Run(an))
20
		_ = srv.server.groupFindsByFile(finds)
21
	}
22
}