可以利用此函数,全局改变函数输入输出
func ExecuTime(f interface{}, params ...interface{}) {
funcValue := reflect.ValueOf(f)
paramList := make([]reflect.Value, 0)
for _, v := range params {
paramList = append(paramList, reflect.ValueOf(v))
}
start := time.Now()
funcValue.Call(paramList)
dur := time.Since(start)
fmt.Println(dur)
}
有疑问加站长微信联系(非本文作者)