May 22, 2015

Golang: measure time to execute code

Sometimes you want to know how long it takes to execute a piece of code. This is how to do it Golang:

func main() {
start := time.Now()

// Do something time consuming

elapsed := time.Since(start)
log.Printf("Time to execute code %s", elapsed)


Leave a Reply

Your email address will not be published. Required fields are marked *

XFerion Europe LLP
We build an maintain your software. From web to mobile. From MVP to extended product. Contact us if you wish to discuss a project.