MCPcopy Index your code
hub / github.com/riverqueue/river / BenchmarkReplacer

Function BenchmarkReplacer

rivershared/sqlctemplate/sqlc_template_test.go:501–533  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

499}
500
501func BenchmarkReplacer(b *testing.B) {
502 ctx := context.Background()
503
504 runReplacer := func(b *testing.B, replacer *Replacer, stable bool) {
505 b.Helper()
506
507 ctx := WithReplacements(ctx, map[string]Replacement{
508 "schema": {Stable: stable, Value: "test_schema."},
509 }, nil)
510
511 _, _, err := replacer.RunSafely(ctx, "$", `
512 -- name: JobCountByState :one
513 SELECT count(*)
514 FROM /* TEMPLATE: schema */river_job
515 WHERE state = @state;
516 `, nil)
517 require.NoError(b, err)
518 }
519
520 b.Run("WithCache", func(b *testing.B) {
521 var replacer Replacer
522 for range b.N {
523 runReplacer(b, &replacer, true)
524 }
525 })
526
527 b.Run("WithoutCache", func(b *testing.B) {
528 var replacer Replacer
529 for range b.N {
530 runReplacer(b, &replacer, false)
531 }
532 })
533}

Callers

nothing calls this directly

Calls 4

RunSafelyMethod · 0.95
WithReplacementsFunction · 0.85
HelperMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…