Documentation ¶
Overview ¶
Package stats provides Stats
Index ¶
- type Progress
- type Stage
- type StageStats
- type Stats
- func (st *Stats) All() []StageStats
- func (st *Stats) Close()
- func (st *Stats) Current() StageStats
- func (st *Stats) Diff() perf.Diff
- func (st *Stats) DoStage(stage Stage, f func() error) error
- func (st *Stats) Done() bool
- func (st *Stats) End() (prev StageStats)
- func (st *Stats) IndexStats() igraph.Stats
- func (st *Stats) Log(message string, fields ...any)
- func (st *Stats) LogDebug(message string, fields ...any)
- func (st *Stats) LogError(message string, err error, fields ...any)
- func (st *Stats) LogFatal(message string, err error)
- func (st *Stats) Progress() (progress Progress)
- func (st *Stats) Rewritable() *progress.Rewritable
- func (st *Stats) SetCT(current, total int)
- func (st *Stats) Start(stage Stage)
- func (st *Stats) StoreIndexStats(stats igraph.Stats)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stage ¶
type Stage string
Stage represents a stage used for statistics
const ( StageInitial Stage = "" StageImportIndex Stage = "import" StageExportIndex Stage = "export" StageExportSQL Stage = "export/sql" StageExportJSON Stage = "export/json" StageReadPathbuilder Stage = "pathbuilder" StageScanSameAs Stage = "index/sameas" StageScanInverse Stage = "index/inverse" StageScanTriples Stage = "index/triples" StageExtractSameAs Stage = "sameas" StageExtractBundles Stage = "bundles" StageExtractCache Stage = "cache" StageHandler Stage = "handler" )
type StageStats ¶
type StageStats struct { Stage Stage Start perf.Snapshot // At the start of the stage End perf.Snapshot // At the end of the stage Current int Total int }
StageStats holds the stats for a specific stage
func (StageStats) Diff ¶
func (ss StageStats) Diff() perf.Diff
Diff returns a diff of the given stage
func (StageStats) Progress ¶
func (ss StageStats) Progress() string
Progress returns a string holding progress information on the current stage
type Stats ¶
type Stats struct { // OnUpdate is called every time this stats updates. // OnUpdate may be nil. OnUpdate func(*Stats) // contains filtered or unexported fields }
Stats holds statistical information about the current stage of the previous. Updating the status writes out detailed information to an underlying io.Writer.
Stats is safe to access concurrently, however the caller is responsible for only logging to one stage at a time.
A nil Stats is valid, and discards any information written to it.
func (*Stats) All ¶
func (st *Stats) All() []StageStats
Current returns a copy of the current StageStats
func (*Stats) Close ¶
func (st *Stats) Close()
Close marks this status as done. Future edits will have no effect.
func (*Stats) Current ¶
func (st *Stats) Current() StageStats
Current returns a copy of the current StageStats
func (*Stats) Diff ¶
Diff returns a performance diff starting at the first, and ending at the last stage. If status is nil, a nil diff is returned.
func (*Stats) DoStage ¶
DoStage is a convenience wrapper to start a new stage, call f, and log the resulting error if any.
If st is nil, immediately invokes f.
func (*Stats) End ¶
func (st *Stats) End() (prev StageStats)
End ends the current stage if any. Any changes are flushed to the underlying writer.
If st is nil, this function has no effect.
func (*Stats) IndexStats ¶
IndexStats returns the current stats for the index
func (*Stats) Log ¶
Log logs an informational message with the provided key, value field pairs.
When status or the associated logger are nil, no logging occurs.
func (*Stats) LogDebug ¶
Log logs a debug message with the provided key, value field pairs.
When status or the associated logger are nil, no logging occurs.
func (*Stats) LogError ¶
LogError logs an error message containing the provided error and the provided key, value field pairs.
When status or the associated logger are nil, no logging occurs.
func (*Stats) LogFatal ¶
LogFatal is like LogError followed by os.Exit(1). When the associated logger are nil, os.Exit(1) is called immediately.
func (*Stats) Rewritable ¶
func (st *Stats) Rewritable() *progress.Rewritable
Rewritable returns the rewritable associated with this status. It is automatically closed at the end of each stage
func (*Stats) SetCT ¶
SetCT sets the current and total for the given stage. It the status is nil, or the status is done, has no effect.
func (*Stats) Start ¶
Start starts a new stage, updating the current property. Any changes are written to the underlying writer.
If st is done or nil, this function has no effect.
func (*Stats) StoreIndexStats ¶
StoreIndexStats optionally stores index statistics. If st is nil or done, this call has no effect