Skip to content

Commit

Permalink
executor: tiny clean up (pingcap#1653)
Browse files Browse the repository at this point in the history
* executor: tiny clean up

* replace more time.Now().Sub() with time.Since()
  • Loading branch information
ngaut authored Aug 29, 2016
1 parent c0058d2 commit a09d282
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion evaluator/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"time"

"fmt"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/ast"
"github.com/pingcap/tidb/model"
Expand Down Expand Up @@ -112,7 +113,7 @@ func (s *testEvaluatorSuite) TestSleep(c *C) {
ret, err = builtinSleep(d, ctx)
c.Assert(err, IsNil)
c.Assert(ret, DeepEquals, types.NewIntDatum(0))
sub := time.Now().Sub(start)
sub := time.Since(start)
c.Assert(sub.Nanoseconds(), GreaterEqual, int64(0.5*1e9))
}

Expand Down
6 changes: 3 additions & 3 deletions executor/executor_xapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ func (e *XSelectIndexExec) nextForDoubleRead() (*Row, error) {
if e.taskCurr == nil {
taskCurr, ok := <-e.tasks
if !ok {
log.Debugf("[TIME_INDEX_TABLE_SCAN] time: %v", time.Now().Sub(startTs))
log.Debugf("[TIME_INDEX_TABLE_SCAN] time: %v", time.Since(startTs))
return nil, e.tasksErr
}
e.taskCurr = taskCurr
Expand Down Expand Up @@ -807,7 +807,7 @@ func (e *XSelectIndexExec) fetchHandles(idxResult xapi.SelectResult, ch chan<- *
if err != nil || finish {
e.tasksErr = errors.Trace(err)
log.Debugf("[TIME_INDEX_SCAN] time: %v handles: %d concurrency: %d",
time.Now().Sub(startTs),
time.Since(startTs),
totalHandles,
concurrency)
return
Expand Down Expand Up @@ -1115,7 +1115,7 @@ func (e *XSelectTableExec) Next() (*Row, error) {
if e.partialResult == nil {
return nil, nil
}
duration := time.Now().Sub(startTs)
duration := time.Since(startTs)
if duration > 30*time.Millisecond {
log.Infof("[TIME_TABLE_SCAN] %v", duration)
} else {
Expand Down
4 changes: 2 additions & 2 deletions server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (cc *clientConn) dispatch(data []byte) error {
startTs := time.Now()
defer func() {
cc.server.releaseToken(token)
log.Debugf("[TIME_CMD] %v %d", time.Now().Sub(startTs), cmd)
log.Debugf("[TIME_CMD] %v %d", time.Since(startTs), cmd)
}()

switch cmd {
Expand Down Expand Up @@ -398,7 +398,7 @@ func (cc *clientConn) handleQuery(sql string) (err error) {
} else {
err = cc.writeOK()
}
costTime := time.Now().Sub(startTs)
costTime := time.Since(startTs)
if len(sql) > 1024 {
sql = sql[:1024]
}
Expand Down
4 changes: 2 additions & 2 deletions store/tikv/gc_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (w *GCWorker) resolveLocks(safePoint uint64) error {
break
}
}
log.Infof("[gc worker] %s finish resolve locks, safePoint: %v, regions: %v, total resolved: %v, cost time: %s", w.uuid, safePoint, regions, totalResolvedLocks, time.Now().Sub(startTime))
log.Infof("[gc worker] %s finish resolve locks, safePoint: %v, regions: %v, total resolved: %v, cost time: %s", w.uuid, safePoint, regions, totalResolvedLocks, time.Since(startTime))
return nil
}

Expand Down Expand Up @@ -238,7 +238,7 @@ func (w *GCWorker) doGC(safePoint uint64) error {
break
}
}
log.Infof("[gc worker] %s finish gc, safePoint: %v, regions: %v, cost time: %s", w.uuid, safePoint, regions, time.Now().Sub(startTime))
log.Infof("[gc worker] %s finish gc, safePoint: %v, regions: %v, cost time: %s", w.uuid, safePoint, regions, time.Since(startTime))
return nil
}

Expand Down

0 comments on commit a09d282

Please sign in to comment.