Skip to content

Commit

Permalink
humanize byte size printing
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Oct 24, 2018
1 parent f1252e4 commit a664e27
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

"github.com/assafmo/joincap/minheap"
humanize "github.com/dustin/go-humanize"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcapgo"
flags "github.com/jessevdk/go-flags"
Expand Down Expand Up @@ -172,19 +173,9 @@ func initHeapWithInputFiles(inputFilePaths []string, minTimeHeap *minheap.Packet
}

if verbose {
mib := float64(totalInputSizeBytes) / 1024 / 1024
gib := mib / 1024
tib := gib / 1024

format := "merging %d input files of size %f %s\n"

if tib > 1 {
log.Printf(format, minTimeHeap.Len(), tib, "TiB")
} else if gib > 1 {
log.Printf(format, minTimeHeap.Len(), gib, "GiB")
} else {
log.Printf(format, minTimeHeap.Len(), mib, "MiB")
}
log.Printf("merging %d input files of size %s\n",
minTimeHeap.Len(),
humanize.IBytes(uint64(totalInputSizeBytes)))
}

return linkType, nil
Expand Down

0 comments on commit a664e27

Please sign in to comment.