package profiler
import "github.com/open-policy-agent/opa/v1/profiler"
Package profiler computes and reports on the time spent on expressions.
Index ¶
- type ExprStats
- type ExprStatsAggregated
- type FileReport
- type Profiler
- func New() *Profiler
- func (*Profiler) Config() topdown.TraceConfig
- func (*Profiler) Enabled() bool
- func (p *Profiler) ReportByFile() Report
- func (p *Profiler) ReportTopNResults(numResults int, criteria []string) []ExprStats
- func (p *Profiler) Trace(event *topdown.Event)
- func (p *Profiler) TraceEvent(event topdown.Event)
- type Report
Types ¶
type ExprStats ¶
type ExprStats struct { ExprTimeNs int64 `json:"total_time_ns"` NumEval int `json:"num_eval"` NumRedo int `json:"num_redo"` NumGenExpr int `json:"num_gen_expr"` Location *ast.Location `json:"location"` }
ExprStats represents the result of profiling an expression.
type ExprStatsAggregated ¶
type ExprStatsAggregated struct { ExprTimeNsStats interface{} `json:"total_time_ns_stats"` NumEval int `json:"num_eval"` NumRedo int `json:"num_redo"` NumGenExpr int `json:"num_gen_expr"` Location *ast.Location `json:"location"` }
ExprStatsAggregated represents the result of profiling an expression by aggregating `n` profiles.
func AggregateProfiles ¶
func AggregateProfiles(profiles ...[]ExprStats) []ExprStatsAggregated
type FileReport ¶
type FileReport struct { Result []ExprStats `json:"result"` }
FileReport represents a profiler report for a single file.
type Profiler ¶
type Profiler struct {
// contains filtered or unexported fields
}
Profiler computes and reports on the time spent on expressions.
func New ¶
func New() *Profiler
New returns a new Profiler object.
func (*Profiler) Config ¶
func (*Profiler) Config() topdown.TraceConfig
Config returns the standard Tracer configuration for the profiler
func (*Profiler) Enabled ¶
Enabled returns true if profiler is enabled.
func (*Profiler) ReportByFile ¶
ReportByFile returns a profiler report for expressions grouped by the file name. For each file the results are sorted by increasing row number.
func (*Profiler) ReportTopNResults ¶
ReportTopNResults returns the top N results based on the given criteria. If N <= 0, all the results based on the criteria are returned.
func (*Profiler) Trace ¶
Trace updates the profiler state. Deprecated: Use TraceEvent instead.
func (*Profiler) TraceEvent ¶
TraceEvent updates the coverage state.
type Report ¶
type Report struct { Files map[string]*FileReport `json:"files"` }
Report represents the profiler report for a set of files.
Source Files ¶
- Version
- v1.4.2 (latest)
- Published
- May 2, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 3 weeks ago –
Tools for package owners.