Skip to content

Commit 6cde56d

Browse files
testwillxllora
authored andcommitted
chore: use time.Since instead of time.Now().Sub
1 parent 5166cd3 commit 6cde56d

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

bql/planner/planner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ func (p *queryPlan) processGraphPattern(ctx context.Context, lo *storage.LookupO
811811
addFilterOptions(lo, cls, filterOptionsByClause)
812812
unresolvable, err := p.processClause(ctx, cls, lo)
813813
resetFilterOptions(lo)
814-
tElapsedCurrClause := time.Now().Sub(tStartCurrClause)
814+
tElapsedCurrClause := time.Since(tStartCurrClause)
815815

816816
tracer.V(2).Trace(p.tracer, func() *tracer.Arguments {
817817
return &tracer.Arguments{
@@ -826,7 +826,7 @@ func (p *queryPlan) processGraphPattern(ctx context.Context, lo *storage.LookupO
826826
return nil
827827
}
828828
}
829-
tElapsedClauses := time.Now().Sub(tStartClauses)
829+
tElapsedClauses := time.Since(tStartClauses)
830830
tracer.V(2).Trace(p.tracer, func() *tracer.Arguments {
831831
return &tracer.Arguments{
832832
Msgs: []string{fmt.Sprintf("Finished processing all clauses, total latency: %v", tElapsedClauses)},

tools/vcli/bw/benchmark/benchmark.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ func runBattery(ctx context.Context, st storage.Store, name string, chanSize, bu
9696
fmt.Printf("Run %s benchmark sequentially... ", name)
9797
ts := time.Now()
9898
brs := runtime.RunBenchmarkBatterySequentially(bes)
99-
ds := time.Now().Sub(ts)
99+
ds := time.Since(ts)
100100
fmt.Printf("(%v) done\n", ds)
101101

102102
fmt.Printf("Run %s benchmark concurrently... ", name)
103103
tc := time.Now()
104104
brc := runtime.RunBenchmarkBatteryConcurrently(bes)
105-
dc := time.Now().Sub(tc)
105+
dc := time.Since(tc)
106106
fmt.Printf("(%v) done\n\n", dc)
107107

108108
format := func(br *runtime.BenchResult) string {

tools/vcli/bw/repl/repl.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
160160
fmt.Println("Memoization enabled. Type help; to print help.")
161161
fmt.Println()
162162
defer func() {
163-
fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Now().Sub(sessionStart))
163+
fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Since(sessionStart))
164164
}()
165165

166166
for l := range rl(done) {
@@ -321,7 +321,7 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
321321
args := strings.Split("bw "+strings.TrimSpace(l)[:len(l)-1], " ")
322322
usage := "Wrong syntax\n\n\tload <graph_names_separated_by_commas> <file_path>\n"
323323
export.Eval(ctx, usage, args, driver(), bulkSize)
324-
fmt.Println("[OK] Time spent: ", time.Now().Sub(now))
324+
fmt.Println("[OK] Time spent: ", time.Since(now))
325325
done <- false
326326
continue
327327
}
@@ -330,7 +330,7 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
330330
args := strings.Split("bw "+strings.TrimSpace(l[:len(l)-1]), " ")
331331
usage := "Wrong syntax\n\n\tload <file_path> <graph_names_separated_by_commas>\n"
332332
load.Eval(ctx, usage, args, driver(), bulkSize, builderSize)
333-
fmt.Println("[OK] Time spent: ", time.Now().Sub(now))
333+
fmt.Println("[OK] Time spent: ", time.Since(now))
334334
done <- false
335335
continue
336336
}
@@ -355,28 +355,28 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
355355
} else {
356356
fmt.Printf("Loaded %q and run %d BQL commands successfully\n\n", path, cmds)
357357
}
358-
fmt.Println("Time spent: ", time.Now().Sub(now))
358+
fmt.Println("Time spent: ", time.Since(now))
359359
done <- false
360360
continue
361361
}
362362

363363
now := time.Now()
364364
table, err := runBQL(ctx, l, driver(), chanSize, bulkSize, traceWriter)
365-
bqlDiff := time.Now().Sub(now)
365+
bqlDiff := time.Since(now)
366366
if err != nil {
367367
fmt.Printf("[ERROR] %s\n", err)
368-
fmt.Println("Time spent: ", time.Now().Sub(now))
368+
fmt.Println("Time spent: ", time.Since(now))
369369
fmt.Println()
370370
} else {
371371
if table == nil {
372372
fmt.Printf("[OK] 0 rows retrieved. BQL time: %v. Display time: %v\n",
373-
bqlDiff, time.Now().Sub(now)-bqlDiff)
373+
bqlDiff, time.Since(now)-bqlDiff)
374374
} else {
375375
if len(table.Bindings()) > 0 {
376376
fmt.Println(table.String())
377377
}
378378
fmt.Printf("[OK] %d rows retrieved. BQL time: %v. Display time: %v\n",
379-
table.NumRows(), bqlDiff, time.Now().Sub(now)-bqlDiff)
379+
table.NumRows(), bqlDiff, time.Since(now)-bqlDiff)
380380
}
381381
}
382382
done <- false

0 commit comments

Comments
 (0)