opa-bench - Man Page

Benchmark a Rego query


opa bench  [flags]


Benchmark a Rego query and print the results.

The benchmark command works very similar to 'eval' and will evaluate the query in the same fashion. The evaluation will be repeated a number of times and performance results will be returned.

Example with bundle and input data:

opa bench -b ./policy-bundle -i input.json 'data.authz.allow'

To enable more detailed analysis use the --metrics and --benchmem flags.

The optional "gobench" output format conforms to the Go Benchmark Data Format.


--benchmem[=true] report memory allocations with benchmark results

-b, --bundle="" set bundle file(s) or directory path(s). This flag can be repeated.

--count=1 number of times to repeat each benchmark (default 1)

-d, --data="" set policy or data file(s). This flag can be repeated.

--fail[=true] exits with non-zero exit code on undefined/empty result and errors

-f, --format=pretty set output format

-h, --help[=false] help for bench

--ignore=[] set file and directory names to ignore during loading (e.g., '.*' excludes hidden files)

--import="" set query import(s). This flag can be repeated.

-i, --input="" set input file path

--metrics[=true] report query performance metrics

--package="" set query package

-p, --partial[=false] perform partial evaluation

--stdin[=false] read query from stdin

-I, --stdin-input[=false] read input document from stdin

-u, --unknowns=[input] set paths to treat as unknown during partial evaluation

See Also


Referenced By


Jan 2021