Documentation ¶
Index ¶
- func TaskWithTimeout[T Metrics](timeout time.Duration, f func() T) (T, bool)
- type BaseMetrics
- func AllPackages(pkgs []*packages.Package, mode ssa.BuilderMode) BaseMetrics[*ssa.Program]
- func AllPackagesWithTimeout(t time.Duration, pkgs []*packages.Package, mode ssa.BuilderMode) (BaseMetrics[*ssa.Program], bool)
- func PackagesLoad(config *packages.Config, query string) BaseMetrics[[]*packages.Package]
- func PackagesLoadWithTimeout(t time.Duration, config *packages.Config, query string) (BaseMetrics[[]*packages.Package], bool)
- type CallGraphMetrics
- type Metrics
- type PTAMetrics
- type Series
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TaskWithTimeout ¶ added in v1.2.0
TaskWithTimeout performs a task with collectible metrics in the alloted time limit. It returns the Metrics-wrapped result and 'true' if the operation was completed before the timeout, or the zero Metrics value and 'false' otherwise.
Types ¶
type BaseMetrics ¶
type BaseMetrics[T any] struct { // Time it took to perform task time.Duration Payload T // contains filtered or unexported fields }
BaseMetrics provides a foundation for other metrics to build upon. Basic information include the duration to perform a task, whether the task produced an error, and the result produced by the task.
func AllPackages ¶
func AllPackages(pkgs []*packages.Package, mode ssa.BuilderMode) BaseMetrics[*ssa.Program]
AllPackages builds a list of packages as an SSA program. It also invokes .Build() on the produced SSA program.
func AllPackagesWithTimeout ¶ added in v1.1.0
func AllPackagesWithTimeout(t time.Duration, pkgs []*packages.Package, mode ssa.BuilderMode) (BaseMetrics[*ssa.Program], bool)
AllPackagesWithTimeout builds a list of packages as an SSA program in the alloted time limit. It also invokes .Build() on the produced SSA program.
func PackagesLoad ¶
PackagesLoad loads packages according to the specified configuration and further filters them with `query`. It performs additional filtering when the configuration includes test packages.
func PackagesLoadWithTimeout ¶ added in v1.1.0
func PackagesLoadWithTimeout(t time.Duration, config *packages.Config, query string) (BaseMetrics[[]*packages.Package], bool)
PackagesLoadWithTimeout loads packages according to the specified configuration within the alloted time limit, and further filters them with `query`. It performs additional filtering when the configuration includes test packages.
func (BaseMetrics[T]) Ok ¶
func (m BaseMetrics[T]) Ok() bool
Ok checks whether the desired function failed to execute.
func (BaseMetrics[T]) Unpack ¶
func (m BaseMetrics[T]) Unpack() (T, error)
Unpack extracts the payload wrapped in the metrics, and an error, if one was produced.
func (BaseMetrics[T]) UnpackAny ¶
func (m BaseMetrics[T]) UnpackAny() (any, error)
UnpackAny extracts the payload wrapped in the metrics, and an error, if one was produced. UnpackAny allows the implementation of the Metrics interface.
type CallGraphMetrics ¶
type CallGraphMetrics struct { BaseMetrics[*callgraph.Graph] Functions int // Call graph out degree metrics OutDegreeMax int OutDegreeP50 int OutDegreeP90 int OutDegreeP99 int OutDegreeMode int // Call graph in degree metrics InDegreeMax int InDegreeP50 int InDegreeP90 int InDegreeP99 int InDegreeMode int }
CallGraphMetrics encodes metrics about call graphs e.g. as collected by a PTA/RTA analysis.
func AggregateCallGraphResults ¶ added in v1.2.0
func AggregateCallGraphResults(dir string) []CallGraphMetrics
AggregateCallGraphResults recursively walks a directory, reads every file, and then unparses and aggregates all potential call graph metrics in the contents.
func GetCallGraphMetrics ¶
func GetCallGraphMetrics(cg *callgraph.Graph) CallGraphMetrics
GetCallGraphMetrics constructs metrics from a given call graph.
func UnparseCallGraphMetricsFromReader ¶ added in v1.2.0
func UnparseCallGraphMetricsFromReader(r io.Reader) []CallGraphMetrics
UnparseCallGraphMetricsFromReader reads the whole content of a reader and then unparses it line by line. Any reconstructed CallGraphMetrics values are aggregated and then returned in a slice.
func (CallGraphMetrics) CallGraphInDegreeMetrics ¶
func (m CallGraphMetrics) CallGraphInDegreeMetrics() CallGraphMetrics
CallGraphOutdegreeMetrics computes in-degree metrics on the call graph.
func (CallGraphMetrics) CallGraphOutDegreeMetrics ¶
func (m CallGraphMetrics) CallGraphOutDegreeMetrics() CallGraphMetrics
CallGraphOutDegreeMetrics computes out-degree metrics on the call graph. The out degree is computed per-call site. Every function without outgoing calls contributes with a 0 to the statistics.
func (CallGraphMetrics) NumberOfFunctions ¶
func (m CallGraphMetrics) NumberOfFunctions() int
NumberOfFunctions produces the number of functions in the call-graph produced by the Points-To analysis.
func (CallGraphMetrics) String ¶
func (m CallGraphMetrics) String() string
type PTAMetrics ¶
type PTAMetrics struct { BaseMetrics[*pointer.Result] Queries int IndirectQueries int // Maximum points-to set size. PointsToSetSizeMax int PointsToSetSizeP50 int PointsToSetSizeP90 int PointsToSetSizeP99 int PointsToSetSizeMode int }
PTAMetrics aggregates important metrics about the points-to analysis.
func AggregatePTAResults ¶ added in v1.2.0
func AggregatePTAResults(dir string) []PTAMetrics
AggregatePTAResults recursively walks a directory, reads every file, and then unparses and aggregates all potential PTA metrics in the contents.
func Analyze ¶
func Analyze(config *pointer.Config) PTAMetrics
Analyze runs the points-to analysis with the given configuration, collecting metrics i.e., duration and information about the call graph.
func AnalyzeWithTimeout ¶ added in v1.1.0
AnalyzeWithTimeout runs the points-to analysis with the given configuration in the alloted time limit, collecting metrics i.e., duration and information about the call graph.
func UnparsePTAResultsFromReader ¶ added in v1.2.0
func UnparsePTAResultsFromReader(r io.Reader) []PTAMetrics
UnparsePTAResultsFromReader reads the whole content of a reader and then unparses it line by line. Any reconstructed PTAMetrics values are aggregated and then returned in a slice.
func (PTAMetrics) PointsToSetMetrics ¶
func (m PTAMetrics) PointsToSetMetrics() PTAMetrics
PointsToSetMetrics computes metrics about the sizes of points-to sets.
func (PTAMetrics) String ¶
func (m PTAMetrics) String() string
type Series ¶ added in v1.2.0
type Series[T constraints.Ordered] []T
Series is a sequence of orderable values.
func MakeSeries ¶ added in v1.2.0
func MakeSeries[T any, U constraints.Ordered](get func(T) U, ts ...T) Series[U]
MakeSeries creates an ordered series from a data list, given a transformation function over data in the list.
func (Series[T]) Max ¶ added in v1.2.0
func (s Series[T]) Max() T
Max returns the largest value in the series.
func (Series[T]) Mode ¶ added in v1.2.0
func (s Series[T]) Mode() T
Mode returns the most common value in the series.
func (Series[T]) Order ¶ added in v1.2.0
func (s Series[T]) Order() []T
Order returns a sorted copy of the original series, but where all elements have been ordered.
func (Series[T]) P50 ¶ added in v1.2.0
func (s Series[T]) P50() T
P50 returns the smallest value in the 50'th percentile of the series.