cloudflare/pint

Public

mirrored from https://github.com/cloudflare/pintAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.59.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmd/pint/bench_test.go

47lines · modecode

1package main
2
3import (
4 "context"
5 "log/slog"
6 "testing"
7
8 "github.com/prometheus/client_golang/prometheus"
9
10 "github.com/cloudflare/pint/internal/config"
11 "github.com/cloudflare/pint/internal/discovery"
12 "github.com/cloudflare/pint/internal/git"
13 "github.com/cloudflare/pint/internal/log"
14)
15
16func BenchmarkFindEntries(b *testing.B) {
17 log.Setup(slog.LevelError, true)
18
19 finder := discovery.NewGlobFinder(
20 []string{"bench/rules"},
21 git.NewPathFilter(nil, nil, nil),
22 )
23 for n := 0; n < b.N; n++ {
24 _, _ = finder.Find()
25 }
26}
27
28func BenchmarkCheckRules(b *testing.B) {
29 log.Setup(slog.LevelError, true)
30
31 finder := discovery.NewGlobFinder(
32 []string{"bench/rules"},
33 git.NewPathFilter(nil, nil, nil),
34 )
35 entries, err := finder.Find()
36 if err != nil {
37 b.Errorf("Find() error: %s", err)
38 b.FailNow()
39 }
40
41 ctx := context.Background()
42 cfg, _ := config.Load("", false)
43 gen := config.NewPrometheusGenerator(cfg, prometheus.NewRegistry())
44 for n := 0; n < b.N; n++ {
45 _, _ = checkRules(ctx, 10, true, gen, cfg, entries)
46 }
47}