title: How to test Go function execution time using standard lib
body: <p>I've written the following function that when used with <code>Defer</code> will surely do the trick but is there something in standard library I could use for this? I'm looking something similar to Python <code>timeit</code> which I could use directly from the shell?</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "time"
  )
  
  func main() {
      defer timeTrack(time.Now(), "looptest")
      nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
      var m []int
      for n := range nums {
          if n%2 == 0 {
              m = append(m, n)
          }
      }
  }
  
  func timeTrack(start time.Time, name string) {
      elapsed := time.Since(start)
      fmt.Printf("%s took %s", name, elapsed)
  }
  </code></pre>