summaryrefslogtreecommitdiff
path: root/timer.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-09 15:34:53 -0600
committerJeff Carr <[email protected]>2024-01-09 15:34:53 -0600
commit87346d9452b38db517e76e070f11928060bc2b99 (patch)
tree2e6ff93e368fda0a1581496985798fe4c1de3569 /timer.go
initial commit
Diffstat (limited to 'timer.go')
-rw-r--r--timer.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/timer.go b/timer.go
new file mode 100644
index 0000000..9e9e589
--- /dev/null
+++ b/timer.go
@@ -0,0 +1,17 @@
+package repostatus
+
+import (
+ "time"
+)
+
+// timeFunction takes a function as an argument and returns the execution time.
+func timeFunction(f func()) time.Duration {
+ startTime := time.Now() // Record the start time
+ f() // Execute the function
+ return time.Since(startTime) // Calculate the elapsed time
+}
+
+func (ls *RepoStatus) SetSpeedActual(s string) {
+ if ! ls.Ready() {return}
+ ls.speedActual.Set(s)
+}