diff --git a/m/reader.go b/m/reader.go index ce02d29..92c1f65 100644 --- a/m/reader.go +++ b/m/reader.go @@ -110,7 +110,7 @@ func (reader *Reader) readStream(stream io.Reader, originalFileName *string, onD bufioReader := bufio.NewReader(stream) completeLine := make([]byte, 0) - t0 := time.Now().UnixNano() + t0 := time.Now() for { keepReadingLine := true eof := false @@ -171,9 +171,8 @@ func (reader *Reader) readStream(stream io.Reader, originalFileName *string, onD onDone() } - t1 := time.Now().UnixNano() - dtNanos := t1 - t0 - log.Debug("Stream read in ", dtNanos/1_000_000, "ms") + t1 := time.Now() + log.Debug("Stream read in ", t1.Sub(t0)) } // NewReaderFromStream creates a new stream reader @@ -307,7 +306,7 @@ func countLines(filename string) (uint64, error) { }() var count uint64 - t0 := time.Now().UnixNano() + t0 := time.Now() buf := make([]byte, bufio.MaxScanTokenSize) lastReadEndsInNewline := true for { @@ -331,12 +330,11 @@ func countLines(filename string) (uint64, error) { count++ } - t1 := time.Now().UnixNano() - dtNanos := t1 - t0 + t1 := time.Now() if count == 0 { - log.Debug("Counted ", count, " lines in 0ms") + log.Debug("Counted ", count, " lines in ", t1.Sub(t0)) } else { - log.Debug("Counted ", count, " lines in ", dtNanos/1_000_000, "ms at ", dtNanos/int64(count), "ns/line") + log.Debug("Counted ", count, " lines in ", t1.Sub(t0), " at ", (t1.Sub(t0))/time.Duration(count), "/line") } return count, nil } diff --git a/moar.go b/moar.go index 2ca0d04..8ecfc7f 100644 --- a/moar.go +++ b/moar.go @@ -611,6 +611,8 @@ func decodeStyleOption(styleOption **chroma.Style) chroma.Style { return **styleOption } + t0 := time.Now() + // Prep for querying the terminal background color oldTerminalState, err := term.MakeRaw(int(os.Stdout.Fd())) if err != nil { @@ -676,6 +678,9 @@ func decodeStyleOption(styleOption **chroma.Style) chroma.Style { return *styles.Get(defaultDarkTheme) } + t1 := time.Now() + log.Debug("Terminal background color detection took ", t1.Sub(t0)) + color := twin.NewColor24Bit(uint8(red/256), uint8(green/256), uint8(blue/256)) log.Debug("Terminal background color detected: ", color)