misc:TimeFunc: reduce printed time precision

Now:
        10:57:41.737665 initramfs-extra completed in: 0.33s
        ...
        10:57:42.008587 boot-deploy completed in: 0.27s
        10:57:42.012973 mkinitfs completed in: 0.90s

Times is just truncated, not rounding, since it's simpler (no dependency
on the math module), and I'm not sure if anyone cares for what this
function prints. If there is a desire to return to higher precision
later, it could be enabled by a new flag.

fixes https://gitlab.com/postmarketOS/postmarketos-mkinitfs/-/issues/25
This commit is contained in:
Clayton Craft
2023-03-13 10:58:37 -07:00
parent 67f1839ddc
commit dd3ea35e35

View File

@@ -45,7 +45,7 @@ func RemoveDuplicates(in []string) (out []string) {
// defer misc.TimeFunc(time.Now(), "foo") // defer misc.TimeFunc(time.Now(), "foo")
func TimeFunc(start time.Time, name string) { func TimeFunc(start time.Time, name string) {
elapsed := time.Since(start) elapsed := time.Since(start)
log.Printf("%s completed in: %s", name, elapsed) log.Printf("%s completed in: %.2fs", name, elapsed.Seconds())
} }
// Exists tests if the given file/dir exists or not. Returns any errors related // Exists tests if the given file/dir exists or not. Returns any errors related