From 87346d9452b38db517e76e070f11928060bc2b99 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 9 Jan 2024 15:34:53 -0600 Subject: initial commit --- timer.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 timer.go (limited to 'timer.go') 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) +} -- cgit v1.2.3