MCPcopy Create free account
hub / github.com/github/gh-aw / BenchmarkValidation

Function BenchmarkValidation

pkg/workflow/compiler_performance_benchmark_test.go:266–320  ·  view source on GitHub ↗

BenchmarkValidation benchmarks the validation phase

(b *testing.B)

Source from the content-addressed store, hash-verified

264
265// BenchmarkValidation benchmarks the validation phase
266func BenchmarkValidation(b *testing.B) {
267 tmpDir, err := os.MkdirTemp("", "bench-validate")
268 if err != nil {
269 b.Fatal(err)
270 }
271 defer os.RemoveAll(tmpDir)
272
273 testContent := `---
274on: pull_request
275permissions:
276 contents: read
277 issues: read
278 pull-requests: read
279engine: copilot
280tools:
281 github:
282 mode: remote
283 toolsets: [default]
284 bash: ["git status"]
285strict: true
286timeout-minutes: 10
287---
288
289# Validation Benchmark
290
291Test validation performance.
292`
293
294 testFile := filepath.Join(tmpDir, "validate.md")
295 if err := os.WriteFile(testFile, []byte(testContent), 0644); err != nil {
296 b.Fatal(err)
297 }
298
299 compiler := NewCompiler(WithNoEmit(true))
300 compiler.SetStrictMode(true)
301 compiler.SetQuiet(true)
302
303 workflowData, err := compiler.ParseWorkflowFile(testFile)
304 if err != nil {
305 b.Fatal(err)
306 }
307
308 // Warm up: run once before timing to prime one-time caches (schema compilation, etc.)
309 if err := compiler.validateWorkflowData(workflowData, testFile); err != nil {
310 b.Fatal(err)
311 }
312
313 b.ResetTimer()
314 b.ReportAllocs()
315 for b.Loop() {
316 if err := compiler.validateWorkflowData(workflowData, testFile); err != nil {
317 b.Fatalf("validateWorkflowData failed: %v", err)
318 }
319 }
320}
321
322// BenchmarkYAMLGeneration benchmarks YAML generation from workflow data
323func BenchmarkYAMLGeneration(b *testing.B) {

Callers

nothing calls this directly

Calls 6

SetStrictModeMethod · 0.95
SetQuietMethod · 0.95
ParseWorkflowFileMethod · 0.95
validateWorkflowDataMethod · 0.95
NewCompilerFunction · 0.85
WithNoEmitFunction · 0.85

Tested by

no test coverage detected