Skip to content

Commit

Permalink
fix client side time (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince authored Jul 5, 2021
1 parent 353e911 commit eb8bb28
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit eb8bb28

Please sign in to comment.