clerk/internal/lsp/diagnostics_test.go (view raw)
Oleksandr Smirnov
Oleksandr Smirnov
olexsmir@gmail.com lsp: cache per-document analyses with include-aware invalidation..., 1 month ago
olexsmir@gmail.com lsp: cache per-document analyses with include-aware invalidation..., 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 := openJouranl(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 | } |