From 284a6084197c7e903a8f7a5bdc5db907cf0a3500 Mon Sep 17 00:00:00 2001 From: Edward Date: Wed, 6 May 2020 17:23:37 +0800 Subject: [PATCH] add missing package --- profiling/profile.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/profiling/profile.go b/profiling/profile.go index e123f45..7b615c6 100644 --- a/profiling/profile.go +++ b/profiling/profile.go @@ -1,25 +1,26 @@ package profile import ( - "time" - "log" + "log" + "math/big" + "time" ) func Duration(invocation time.Time, name string) { - elapsed := time.Since(invocation) + elapsed := time.Since(invocation) - log.Printf("%s lasted %s", name, elapsed) + log.Printf("%s lasted %s", name, elapsed) } 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 Duration(time.Now(), "IntFactorial") + // Arguments to a defer statement is immediately evaluated and stored. + // The deferred function receives the pre-evaluated values when its invoked. + defer Duration(time.Now(), "IntFactorial") - y := big.NewInt(1) - for one := big.NewInt(1); x.Sign() > 0; x.Sub(x, one) { - y.Mul(y, x) - } + y := big.NewInt(1) + for one := big.NewInt(1); x.Sign() > 0; x.Sub(x, one) { + y.Mul(y, x) + } - return x.Set(y) + return x.Set(y) }