mirror of
https://github.com/tmrts/go-patterns.git
synced 2026-02-03 22:36:19 +00:00
profiling/timing: elaborate on deferred function evaluation
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user