Repos / s4g / 76de1230d0
commit 76de1230d0c90458c627c60726db6bb62a338300
Author: Nhân <hi@imnhan.com>
Date: Fri Jul 7 22:20:44 2023 +0700
print regeneration time
diff --git a/main.go b/main.go
index ba6daf7..6ff70fc 100644
--- a/main.go
+++ b/main.go
@@ -57,6 +57,7 @@ func main() {
}
func regenerate(fsys WritableFS) {
+ defer timer("Took %s")()
site := readSiteMetadata(fsys)
articles := findArticles(fsys)
diff --git a/utils.go b/utils.go
new file mode 100644
index 0000000..32dec8f
--- /dev/null
+++ b/utils.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+ "time"
+)
+
+func timer(format string) func() {
+ start := time.Now()
+ return func() {
+ fmt.Printf(format+"\n", time.Since(start))
+ }
+}
+
+func contains(s []string, e string) bool {
+ for _, a := range s {
+ if a == e {
+ return true
+ }
+ }
+ return false
+}
diff --git a/watcher.go b/watcher.go
index 33acb06..36d9dc9 100644
--- a/watcher.go
+++ b/watcher.go
@@ -100,12 +100,3 @@ func printWatchList(w *fsnotify.Watcher) {
fmt.Println(" " + path)
}
}
-
-func contains(s []string, e string) bool {
- for _, a := range s {
- if a == e {
- return true
- }
- }
- return false
-}