Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use time.Since instead of time.Now().Sub #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bql/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ func (p *queryPlan) processGraphPattern(ctx context.Context, lo *storage.LookupO
addFilterOptions(lo, cls, filterOptionsByClause)
unresolvable, err := p.processClause(ctx, cls, lo)
resetFilterOptions(lo)
tElapsedCurrClause := time.Now().Sub(tStartCurrClause)
tElapsedCurrClause := time.Since(tStartCurrClause)

tracer.V(2).Trace(p.tracer, func() *tracer.Arguments {
return &tracer.Arguments{
Expand All @@ -826,7 +826,7 @@ func (p *queryPlan) processGraphPattern(ctx context.Context, lo *storage.LookupO
return nil
}
}
tElapsedClauses := time.Now().Sub(tStartClauses)
tElapsedClauses := time.Since(tStartClauses)
tracer.V(2).Trace(p.tracer, func() *tracer.Arguments {
return &tracer.Arguments{
Msgs: []string{fmt.Sprintf("Finished processing all clauses, total latency: %v", tElapsedClauses)},
Expand Down
4 changes: 2 additions & 2 deletions tools/vcli/bw/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ func runBattery(ctx context.Context, st storage.Store, name string, chanSize, bu
fmt.Printf("Run %s benchmark sequentially... ", name)
ts := time.Now()
brs := runtime.RunBenchmarkBatterySequentially(bes)
ds := time.Now().Sub(ts)
ds := time.Since(ts)
fmt.Printf("(%v) done\n", ds)

fmt.Printf("Run %s benchmark concurrently... ", name)
tc := time.Now()
brc := runtime.RunBenchmarkBatteryConcurrently(bes)
dc := time.Now().Sub(tc)
dc := time.Since(tc)
fmt.Printf("(%v) done\n\n", dc)

format := func(br *runtime.BenchResult) string {
Expand Down
16 changes: 8 additions & 8 deletions tools/vcli/bw/repl/repl.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
fmt.Println("Memoization enabled. Type help; to print help.")
fmt.Println()
defer func() {
fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Now().Sub(sessionStart))
fmt.Printf("\n\nThanks for all those BQL queries!\nSession duration: %v\n\n", time.Since(sessionStart))
}()

for l := range rl(done) {
Expand Down Expand Up @@ -321,7 +321,7 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
args := strings.Split("bw "+strings.TrimSpace(l)[:len(l)-1], " ")
usage := "Wrong syntax\n\n\tload <graph_names_separated_by_commas> <file_path>\n"
export.Eval(ctx, usage, args, driver(), bulkSize)
fmt.Println("[OK] Time spent: ", time.Now().Sub(now))
fmt.Println("[OK] Time spent: ", time.Since(now))
done <- false
continue
}
Expand All @@ -330,7 +330,7 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
args := strings.Split("bw "+strings.TrimSpace(l[:len(l)-1]), " ")
usage := "Wrong syntax\n\n\tload <file_path> <graph_names_separated_by_commas>\n"
load.Eval(ctx, usage, args, driver(), bulkSize, builderSize)
fmt.Println("[OK] Time spent: ", time.Now().Sub(now))
fmt.Println("[OK] Time spent: ", time.Since(now))
done <- false
continue
}
Expand All @@ -355,28 +355,28 @@ func REPL(od storage.Store, input *os.File, rl ReadLiner, chanSize, bulkSize, bu
} else {
fmt.Printf("Loaded %q and run %d BQL commands successfully\n\n", path, cmds)
}
fmt.Println("Time spent: ", time.Now().Sub(now))
fmt.Println("Time spent: ", time.Since(now))
done <- false
continue
}

now := time.Now()
table, err := runBQL(ctx, l, driver(), chanSize, bulkSize, traceWriter)
bqlDiff := time.Now().Sub(now)
bqlDiff := time.Since(now)
if err != nil {
fmt.Printf("[ERROR] %s\n", err)
fmt.Println("Time spent: ", time.Now().Sub(now))
fmt.Println("Time spent: ", time.Since(now))
fmt.Println()
} else {
if table == nil {
fmt.Printf("[OK] 0 rows retrieved. BQL time: %v. Display time: %v\n",
bqlDiff, time.Now().Sub(now)-bqlDiff)
bqlDiff, time.Since(now)-bqlDiff)
} else {
if len(table.Bindings()) > 0 {
fmt.Println(table.String())
}
fmt.Printf("[OK] %d rows retrieved. BQL time: %v. Display time: %v\n",
table.NumRows(), bqlDiff, time.Now().Sub(now)-bqlDiff)
table.NumRows(), bqlDiff, time.Since(now)-bqlDiff)
}
}
done <- false
Expand Down