Documentation
¶
Overview ¶
Package ptimer provides a progress timer for iterative processes.
A timer prints how much time passed since its creation at exponentially growing time-points. Precisely, prints are triggered after i calls to Inc, if i has only one non-zero digit. That is: 1, 2, 3 .. 9, 10, 20, 30 .. 90, 100, 200, 300...
Output Format ¶
For a regular use:
00:00:00.000000 (00:00:00.000000) message
| | |
Total time since creation | |
| |
Average time per call to Inc |
|
User-defined message ----------------|
(default message is number of calls to Inc)
When calling Done without calling Inc:
00:00:00.000000 message
Example ¶
pt := New()
for i := 0; i < 45; i++ {
time.Sleep(100 * time.Millisecond)
pt.Inc()
}
pt.Done()
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Timer ¶
type Timer struct {
N int // Current count, incremented with each call to Inc
W io.Writer // Timer's output, defaults to stderr
// contains filtered or unexported fields
}
A Timer measures time during iterative processes and prints the progress on exponential checkpoints.
func NewFunc ¶
NewFunc returns a new timer that calls f with the current count on checkpoints, and prints its output.
func NewMessage ¶ added in v0.4.0
NewMessage returns a new timer that prints msg on checkpoints. A "{}" in msg will be replaced with the current count.