Merge pull request #36 from webp-sh/prefetch

Add prefetch elapsed time
This commit is contained in:
Nova Kwok 2020-04-01 23:34:47 +08:00 committed by GitHub
commit 98650634a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"time"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
@ -12,6 +13,7 @@ import (
) )
func PrefetchImages(confImgPath string, ExhaustPath string, QUALITY string) { func PrefetchImages(confImgPath string, ExhaustPath string, QUALITY string) {
var sTime = time.Now()
// maximum ongoing prefetch is depending on your core of CPU // maximum ongoing prefetch is depending on your core of CPU
log.Infof("Prefetching using %d cores", jobs) log.Infof("Prefetching using %d cores", jobs)
var finishChan = make(chan int, jobs) var finishChan = make(chan int, jobs)
@ -41,7 +43,8 @@ func PrefetchImages(confImgPath string, ExhaustPath string, QUALITY string) {
if err != nil { if err != nil {
log.Debug(err) log.Debug(err)
} }
elapsed := time.Since(sTime)
_, _ = fmt.Fprintf(os.Stdout, "Prefetch completeY(^_^)Y\n\n") _, _ = fmt.Fprintf(os.Stdout, "Prefetch completeY(^_^)Y\n\n")
_, _ = fmt.Fprintf(os.Stdout, "Convert %d file in %s (^_^)Y\n\n", count, elapsed)
} }