August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this section, you are going to learn how to measure the execution time of one or more commands in Go. The same technique can be applied for measuring the execution time of a function or a group of functions. The name of the Go program is execTime.go and it will be presented in three parts.
The first part of execTime.go is as follows:
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
time.Sleep(time.Second)
duration := time.Since(start)
fmt.Println("It took time.Sleep(1)", duration, "to finish.")
You will need the functionality offered by the time package in order to measure ...
Read now
Unlock full access