opa-bench(1)
| Open Policy Agent(1) | Open Policy Agent(1) |
NAME
opa-bench - Benchmark a Rego query
SYNOPSIS
opa bench [flags]
DESCRIPTION
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 run benchmarks against a running OPA server to evaluate server overhead use the --e2e flag. To enable more detailed analysis use the --metrics and --benchmem flags.
The optional "gobench" output format conforms to the Go Benchmark Data Format.
OPTIONS
--benchmem[=true] report memory allocations with benchmark results
-b, --bundle="" set bundle file(s) or directory path(s). This flag can be repeated.
-c, --config-file="" set path of configuration file
--count=1 number of times to repeat each benchmark
-d, --data="" set policy or data file(s). This flag can be repeated.
--e2e[=false] run benchmarks against a running OPA server
--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
--optimize-store-for-read-speed[=false] optimize default in-memory store for read speed. Has possible negative impact on memory footprint and write speed. See https://www.openpolicyagent.org/docs/latest/policy-performance/#storage-optimization for more details.
--package="" set query package
-p, --partial[=false] perform partial evaluation
-s, --schema="" set schema file path or directory path
--shutdown-grace-period=10 set the time (in seconds) that the server will wait to gracefully shut down. This flag is valid in 'e2e' mode only.
--shutdown-wait-period=0 set the time (in seconds) that the server will wait before initiating shutdown. This flag is valid in 'e2e' mode only.
--stdin[=false] read query from stdin
-I, --stdin-input[=false] read input document from stdin
-t, --target=rego set the runtime to exercise
-u, --unknowns=[input] set paths to treat as unknown during partial evaluation
--v0-compatible[=false] opt-in to OPA features and behaviors prior to the OPA v1.0 release
SEE ALSO
opa(1)
| Oct 2026 |
