virtigoctl/watchdog.go

13 lines
329 B
Go
Raw Normal View History

2024-10-30 02:28:53 -05:00
package main
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
}