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

Function BenchmarkUnquoteYAMLKey

pkg/workflow/yaml_test.go:513–538  ·  view source on GitHub ↗

BenchmarkUnquoteYAMLKey measures single-pass regex replacement performance. This benchmark guards against regressions where the implementation calls FindStringSubmatch inside a ReplaceAllStringFunc callback (double regex pass).

(b *testing.B)

Source from the content-addressed store, hash-verified

511// This benchmark guards against regressions where the implementation calls
512// FindStringSubmatch inside a ReplaceAllStringFunc callback (double regex pass).
513func BenchmarkUnquoteYAMLKey(b *testing.B) {
514 // A realistic workflow YAML with the "on" key quoted by the marshaler
515 yamlStr := `"on":
516 push:
517 branches:
518 - main
519 pull_request:
520 types:
521 - opened
522 - synchronize
523 issues:
524 types:
525 - opened
526 workflow_dispatch:
527jobs:
528 agent:
529 runs-on: ubuntu-latest
530 steps:
531 - name: Run
532 run: echo hello
533`
534 b.ReportAllocs()
535 for b.Loop() {
536 _ = UnquoteYAMLKey(yamlStr, "on")
537 }
538}
539
540func TestFormatYAMLValue(t *testing.T) {
541 tests := []struct {

Callers

nothing calls this directly

Calls 1

UnquoteYAMLKeyFunction · 0.85

Tested by

no test coverage detected