(b *testing.B)
| 499 | } |
| 500 | |
| 501 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…