github.com/cheng762/platon-go@v1.8.17-0.20190529111256-7deff2d7be26/common/timeUtil.go (about)

     1  package common
     2  
     3  import "time"
     4  
     5  type Timer struct {
     6  	start time.Time
     7  }
     8  
     9  func NewTimer () *Timer {
    10  	return new(Timer)
    11  }
    12  
    13  func (t *Timer) Begin() {
    14  	t.start = time.Now()
    15  }
    16  
    17  func (t *Timer) End() float64 {
    18  	tns := time.Since(t.start).Nanoseconds()
    19  	tms := float64(tns) / float64(1e6)
    20  	return tms
    21  
    22  }