time spent golang code example
Example: goland print the time it took for code to run
package main
import (
"time" // Import this to be able to track time
"fmt" // Import this to print in console
)
//This app will check how long it takes for the computer to print 2000 numbers
func main () {
start := time.Now()
for i := 0; i < 2000; i++{
fmt.Println(i)
}
elapsed := time.Since(start) // This will check how long has passed since time.Now() was executed
fmt.Println(elapsed)
}