Skip to content

Commit be5ca39

Browse files
authored
Add Regal bundle compilation benchmark (#1618)
This is really testing OPA rather than Regal, but since it's a good test case for improving OPA for Regal, it belongs here. Used in open-policy-agent/opa#7740 Signed-off-by: Anders Eknert <anders@styra.com>
1 parent 0d5aae1 commit be5ca39

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ linters:
8080
- path: '(.+)_test\.go'
8181
linters:
8282
- forcetypeassert
83+
- godot
8384
generated: lax
8485
presets:
8586
- comments
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package compile
2+
3+
import (
4+
"testing"
5+
6+
"github.com/styrainc/regal/bundle"
7+
)
8+
9+
// 16 66555594 ns/op 50239492 B/op 1083664 allocs/op - main
10+
// 18 62569440 ns/op 38723015 B/op 944277 allocs/op - compiler-optimizations pr
11+
func BenchmarkCompileBundle(b *testing.B) {
12+
bndl := bundle.LoadedBundle
13+
14+
compiler := NewCompilerWithRegalBuiltins()
15+
16+
for b.Loop() {
17+
if compiler.Compile(bndl.ParsedModules("regal")); len(compiler.Errors) > 0 {
18+
b.Fatal(compiler.Errors)
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)