Skip to content

Instantly share code, notes, and snippets.

@kasari
Last active February 22, 2019 09:24
Show Gist options
  • Save kasari/ec3c07e49aa2c740fdb84f7abbab9e6c to your computer and use it in GitHub Desktop.
Save kasari/ec3c07e49aa2c740fdb84f7abbab9e6c to your computer and use it in GitHub Desktop.
雑に実行時間を計測したいときのスニペット
package main
import (
"fmt"
"time"
)
func main() {
timer := func(tag string) func() {
start := time.Now()
return func() {
fmt.Println(tag, time.Now().Sub(start))
}
}
stop := timer("sleep")
// 何かしらの処理
time.Sleep(time.Millisecond * 200)
stop() // sleep 200.896547ms
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment