Skip to content

Commit

Permalink
Improve timing printouts with --debug
Browse files Browse the repository at this point in the history
By reporting stream reading timings as first the reading time and then
the highlighting time.
  • Loading branch information
walles committed Apr 7, 2024
1 parent 2692fd2 commit 4db6045
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions m/reader.go
Expand Up @@ -100,7 +100,7 @@ func (reader *Reader) preAllocLines(originalFileName string) {
}
}

// This function will be update the Reader struct in the background.
// This function will update the Reader struct in the background.
func (reader *Reader) readStream(stream io.Reader, originalFileName *string, onDone func()) {
defer func() {
reader.done.Store(true)
Expand Down Expand Up @@ -191,11 +191,13 @@ func (reader *Reader) readStream(stream io.Reader, originalFileName *string, onD
default:
}

log.Debug("Stream read in ", time.Since(t0))

if onDone != nil {
t1 := time.Now()
onDone()
log.Debug("onDone() took ", time.Since(t1))
}

log.Debug("Stream read in ", time.Since(t0))
}

// Note that you must call reader.SetStyleForHighlighting() after this to get
Expand Down

0 comments on commit 4db6045

Please sign in to comment.