clerk/internal/lsp/textdocument_format_test.go (view raw)
| 1 | package lsp |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "go.lsp.dev/protocol" |
| 7 | "go.lsp.dev/uri" |
| 8 | ) |
| 9 | |
| 10 | func BenchmarkFormatting(b *testing.B) { |
| 11 | content := openJournal(b, "../../journal/testdata/journals/actual-1ktxns-100accts.journal") |
| 12 | |
| 13 | srv := newServer(b) |
| 14 | srv.server.openDoc(uri.URI("file:///test.journal"), content, 1, "journal") |
| 15 | |
| 16 | params := &protocol.DocumentFormattingParams{ |
| 17 | TextDocument: protocol.TextDocumentIdentifier{URI: uri.URI("file:///test.journal")}, |
| 18 | } |
| 19 | // warm up: first request parses and prints |
| 20 | if _, err := srv.server.Formatting(b.Context(), params); err != nil { |
| 21 | b.Fatal(err) |
| 22 | } |
| 23 | b.ReportAllocs() |
| 24 | b.ResetTimer() |
| 25 | for b.Loop() { |
| 26 | if _, err := srv.server.Formatting(b.Context(), params); err != nil { |
| 27 | b.Fatal(err) |
| 28 | } |
| 29 | } |
| 30 | } |