MCPcopy Create free account
hub / github.com/JordanCoin/codemap / TestBenchmarkAstGrep

Function TestBenchmarkAstGrep

scanner/bench_test.go:10–38  ·  view source on GitHub ↗

TestBenchmarkAstGrep benchmarks the ast-grep scanner

(t *testing.T)

Source from the content-addressed store, hash-verified

8
9// TestBenchmarkAstGrep benchmarks the ast-grep scanner
10func TestBenchmarkAstGrep(t *testing.T) {
11 testDir := os.Getenv("BENCH_DIR")
12 if testDir == "" {
13 testDir = ".."
14 }
15
16 scanner, err := NewAstGrepScanner()
17 if err != nil {
18 t.Fatalf("ast-grep scanner error: %v", err)
19 }
20 if !scanner.Available() {
21 t.Skip("sg not available")
22 }
23 defer scanner.Close()
24
25 start := time.Now()
26 results, err := scanner.ScanDirectory(testDir)
27 if err != nil {
28 t.Fatalf("ast-grep scan error: %v", err)
29 }
30
31 var totalFuncs, totalImports int
32 for _, r := range results {
33 totalFuncs += len(r.Functions)
34 totalImports += len(r.Imports)
35 }
36 t.Logf("ast-grep: %v (%d functions, %d imports, %d files)",
37 time.Since(start), totalFuncs, totalImports, len(results))
38}
39
40func TestAstGrepScanner(t *testing.T) {
41 scanner, err := NewAstGrepScanner()

Callers

nothing calls this directly

Calls 4

AvailableMethod · 0.95
CloseMethod · 0.95
ScanDirectoryMethod · 0.95
NewAstGrepScannerFunction · 0.85

Tested by

no test coverage detected