1
0
mirror of https://github.com/tmrts/go-patterns.git synced 2024-11-23 05:26:09 +03:00

profiling/timing: elaborate on deferred function evaluation

This commit is contained in:
Tamer Tas 2017-02-27 10:05:43 +03:00
parent dbb6189bda
commit 6f16086fb0

View File

@ -26,6 +26,8 @@ func Duration(invocation time.Time, name string) {
```go
func BigIntFactorial(x big.Int) *big.Int {
// Arguments to a defer statement is immediately evaluated and stored.
// The deferred function receives the pre-evaluated values when its invoked.
defer profile.Duration(time.Now(), "IntFactorial")
y := big.NewInt(1)