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

fix client side time #116

Merged
merged 1 commit into from
Jul 5, 2021
Merged
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
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func executeConsoleCmd(cmd int, args []string) (newSpace string) {
return newSpace
}

func printResultSet(res *nebula.ResultSet, duration time.Duration) {
func printResultSet(res *nebula.ResultSet, startTime time.Time) (duration time.Duration) {
if !res.IsSucceed() && !res.IsPartialSucceed() {
fmt.Printf("[ERROR (%d)]: %s", res.GetErrorCode(), res.GetErrorMsg())
fmt.Println()
Expand All @@ -200,12 +200,14 @@ func printResultSet(res *nebula.ResultSet, duration time.Duration) {
if res.IsSetData() {
dataSetPrinter.PrintDataSet(res)
numRows := res.GetRowSize()
duration = time.Since(startTime)
if numRows > 0 {
fmt.Printf("Got %d rows (time spent %d/%d us)\n", numRows, res.GetLatency(), duration/1000)
} else {
fmt.Printf("Empty set (time spent %d/%d us)\n", res.GetLatency(), duration/1000)
}
} else {
duration = time.Since(startTime)
fmt.Printf("Execution succeeded (time spent %d/%d us)\n", res.GetLatency(), duration/1000)
}

Expand All @@ -226,6 +228,8 @@ func printResultSet(res *nebula.ResultSet, duration time.Duration) {
planDescPrinter.PrintPlanDesc(res)
}
fmt.Println()

return
}

// Loop the request util fatal or timeout
Expand Down Expand Up @@ -274,11 +278,10 @@ func loop(session *nebula.Session, c cli.Cli) error {
return nil
}
}
duration := time.Since(start)
t1 += res.GetLatency()
t2 += int32(duration / 1000)
if c.Output() {
printResultSet(res, duration)
duration := printResultSet(res, start)
t2 += int32(duration / 1000)
fmt.Println(time.Now().In(time.Local).Format(time.RFC1123))
fmt.Println()
}
Expand Down