Skip to content

Commit

Permalink
Fix the policy benchmark runner (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones authored Aug 13, 2024
1 parent 0e3ead6 commit 5780f08
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion policy/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,16 @@ func (r *runner) bench(b *testing.B) {
for _, tst := range s.Tests {
tc := tst
b.Run(fmt.Sprintf("%s/%s/%s", r.name, section, tc.Name), func(b *testing.B) {
input := map[string]any{}
for k, v := range tc.Input {
if v.Expr == "" {
input[k] = v.Value
continue
}
input[k] = r.eval(b, v.Expr)
}
for i := 0; i < b.N; i++ {
_, _, err := r.prg.Eval(tc.Input)
_, _, err := r.prg.Eval(input)
if err != nil {
b.Fatalf("policy eval failed: %v", err)
}
Expand Down

0 comments on commit 5780f08

Please sign in to comment.