mirror of
https://github.com/tmrts/go-patterns.git
synced 2024-11-23 13:36:08 +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
|
```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)
|
||||||
|
Loading…
Reference in New Issue
Block a user