mirror of
https://github.com/junegunn/fzf.git
synced 2026-05-18 14:29:58 +08:00
Print ingestion time in --bench output
This commit is contained in:
+6
-2
@@ -195,11 +195,13 @@ func Run(opts *Options) (int, error) {
|
|||||||
// Reader
|
// Reader
|
||||||
streamingFilter := opts.Filter != nil && !sort && !opts.Tac && !opts.Sync && opts.Bench == 0
|
streamingFilter := opts.Filter != nil && !sort && !opts.Tac && !opts.Sync && opts.Bench == 0
|
||||||
var reader *Reader
|
var reader *Reader
|
||||||
|
var ingestionStart time.Time
|
||||||
if !streamingFilter {
|
if !streamingFilter {
|
||||||
reader = NewReader(func(data []byte) bool {
|
reader = NewReader(func(data []byte) bool {
|
||||||
return chunkList.Push(data)
|
return chunkList.Push(data)
|
||||||
}, eventBox, executor, opts.ReadZero, opts.Filter == nil)
|
}, eventBox, executor, opts.ReadZero, opts.Filter == nil)
|
||||||
|
|
||||||
|
ingestionStart = time.Now()
|
||||||
readyChan := make(chan bool)
|
readyChan := make(chan bool)
|
||||||
go reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip, initialReload, initialEnv, readyChan)
|
go reader.ReadSource(opts.Input, opts.WalkerRoot, opts.WalkerOpts, opts.WalkerSkip, initialReload, initialEnv, readyChan)
|
||||||
<-readyChan
|
<-readyChan
|
||||||
@@ -283,6 +285,7 @@ func Run(opts *Options) (int, error) {
|
|||||||
} else {
|
} else {
|
||||||
eventBox.Unwatch(EvtReadNew)
|
eventBox.Unwatch(EvtReadNew)
|
||||||
eventBox.WaitFor(EvtReadFin)
|
eventBox.WaitFor(EvtReadFin)
|
||||||
|
ingestionTime := time.Since(ingestionStart)
|
||||||
|
|
||||||
// NOTE: Streaming filter is inherently not compatible with --tail
|
// NOTE: Streaming filter is inherently not compatible with --tail
|
||||||
snapshot, _, _ := chunkList.Snapshot(opts.Tail)
|
snapshot, _, _ := chunkList.Snapshot(opts.Tail)
|
||||||
@@ -316,13 +319,14 @@ func Run(opts *Options) (int, error) {
|
|||||||
}
|
}
|
||||||
avg := total / time.Duration(len(times))
|
avg := total / time.Duration(len(times))
|
||||||
selectivity := float64(matchCount) / float64(totalItems) * 100
|
selectivity := float64(matchCount) / float64(totalItems) * 100
|
||||||
fmt.Printf(" %d iterations avg: %.2fms min: %.2fms max: %.2fms total: %.2fs items: %d matches: %d (%.2f%%)\n",
|
fmt.Printf(" %d iterations avg: %.2fms min: %.2fms max: %.2fms total: %.2fs items: %d matches: %d (%.2f%%) ingestion: %.2fms\n",
|
||||||
len(times),
|
len(times),
|
||||||
float64(avg.Microseconds())/1000,
|
float64(avg.Microseconds())/1000,
|
||||||
float64(minD.Microseconds())/1000,
|
float64(minD.Microseconds())/1000,
|
||||||
float64(maxD.Microseconds())/1000,
|
float64(maxD.Microseconds())/1000,
|
||||||
total.Seconds(),
|
total.Seconds(),
|
||||||
totalItems, matchCount, selectivity)
|
totalItems, matchCount, selectivity,
|
||||||
|
float64(ingestionTime.Microseconds())/1000)
|
||||||
return ExitOk, nil
|
return ExitOk, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user