Last active
March 21, 2017 08:25
-
-
Save mkdym/97c0d1bde4fad7a909024108972224de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"fmt" | |
"time" | |
) | |
type LatencyPrinter struct { | |
beginTime time.Time | |
} | |
func (h *LatencyPrinter) Begin() { | |
h.beginTime = time.Now() | |
} | |
func (h *LatencyPrinter) End(s string) { | |
fmt.Println(s, ". latency:", time.Since(h.beginTime)) | |
} | |
func main() { | |
var h LatencyPrinter | |
h.Begin() | |
defer h.End("test latency") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment