1
0
Fork 0

Use time.Time.Sub function instead of manipulating nanoseconds

This commit is contained in:
Gregory Eremin 2015-10-27 22:47:36 +03:00
parent 79cb745a5d
commit c7db902da2
1 changed files with 4 additions and 4 deletions

View File

@ -132,8 +132,8 @@ func (s *Satan) runWorker() {
}
func (s *Satan) processTask(t *task) {
dur := time.Now().UnixNano() - t.createdAt.UnixNano()
s.runtimeStats.Add(stats.Latency, time.Duration(dur))
dur := time.Now().Sub(t.createdAt)
s.runtimeStats.Add(stats.Latency, dur)
if t.system {
s.processSystemTask(t)
@ -174,8 +174,8 @@ func (s *Satan) processGeneralTask(t *task) {
}()
if s.DaemonStats != nil {
defer func(start time.Time) {
dur := time.Now().UnixNano() - start.UnixNano()
s.DaemonStats.Add(t.daemon.base().String(), time.Duration(dur))
dur := time.Now().Sub(start)
s.DaemonStats.Add(t.daemon.base().String(), dur)
}(time.Now())
}