Benchmark Rego query
rego_benchBenchmark policy queries against your defined input and data paths with opa bench, then review iterations, ns/op, and allocation counts to pinpoint slow rules.
Instructions
Benchmark a Rego query against a policy + input with opa bench. Returns statistical timing data: iterations, ns/op, and allocation counts. Use this to spot slow rules.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Number of times to repeat the benchmark (`--count N`). Defaults to OPA's built-in default of one. Above one, every repetition is returned in `runs`, `fastest` indexes the one the top-level figures come from, and `raw` is omitted since that document is in `runs`. | |
| input | No | Inline input document. | |
| paths | No | Policy / data paths to load. Each must be in an allowed root. | |
| query | Yes | Rego query to benchmark. | |
| inputPath | No | Path to a JSON input file. | |
| v0Compatible | No | Read the policy as Rego v0 (`--v0-compatible`), the syntax OPA used before 1.0: rules without `if`, partial sets as `deny[msg] { ... }`. Needed for a policy that has not been migrated, which OPA 1.x otherwise refuses to load. Where the tool also takes a query, the query is read as v0 too, with the future keywords imported so `in`, `every` and `some x in` still work in it. |