mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-22 04:36:02 +03:00
profiling/timing: elaborate on deferred function evaluation
This commit is contained in:
parent
dbb6189bda
commit
6f16086fb0
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user