time_cost.go 221 B

12345678910111213141516
  1. package check
  2. import (
  3. "time"
  4. "github.com/sirupsen/logrus"
  5. )
  6. func TimeCost(name string) func() {
  7. start := time.Now()
  8. return func() {
  9. tc := time.Since(start)
  10. logrus.Infof("[%s]time cost = %v\n", name, tc)
  11. }
  12. }