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 ```go
func BigIntFactorial(x big.Int) *big.Int { 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") defer profile.Duration(time.Now(), "IntFactorial")
y := big.NewInt(1) y := big.NewInt(1)