未验证 提交 e5bb1fe7 编写于 作者: Y Yang Zhao 提交者: GitHub

feat: taos shell websocket support network/execute/total timing info (#15630)

* feat: taos shell websocket support network/execute/toal timing info

* chore: update taosws-rs

* feat: update taosws 24b199e

* fix: git clean in jenkinsfile2
Co-authored-by: sangshuduo's avatarShuduo Sang <sangshuduo@gmail.com>
上级 5f3432cf
......@@ -40,6 +40,7 @@ def pre_test(){
git reset --hard
cd ${WKC}
git reset --hard
git clean -fxd
'''
script {
if (env.CHANGE_TARGET == 'master') {
......
......@@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taosws-rs.git
GIT_TAG 9de599d
GIT_TAG 24b199e
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
......
......@@ -33,10 +33,11 @@ int shell_conn_ws_server(bool first) {
return 0;
}
static int horizontalPrintWebsocket(WS_RES* wres) {
static int horizontalPrintWebsocket(WS_RES* wres, double* execute_time) {
const void* data = NULL;
int rows;
ws_fetch_block(wres, &data, &rows);
*execute_time += (double)(ws_take_timing(wres)/1E6);
if (!rows) {
return 0;
}
......@@ -72,10 +73,11 @@ static int horizontalPrintWebsocket(WS_RES* wres) {
return numOfRows;
}
static int verticalPrintWebsocket(WS_RES* wres) {
static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) {
int rows = 0;
const void* data = NULL;
ws_fetch_block(wres, &data, &rows);
*pexecute_time += (double)(ws_take_timing(wres)/1E6);
if (!rows) {
return 0;
}
......@@ -112,7 +114,7 @@ static int verticalPrintWebsocket(WS_RES* wres) {
return numOfRows;
}
static int dumpWebsocketToFile(const char* fname, WS_RES* wres) {
static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute_time) {
char fullname[PATH_MAX] = {0};
if (taosExpandDir(fname, fullname, PATH_MAX) != 0) {
tstrncpy(fullname, fname, PATH_MAX);
......@@ -127,6 +129,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres) {
int rows = 0;
const void* data = NULL;
ws_fetch_block(wres, &data, &rows);
*pexecute_time += (double)(ws_take_timing(wres)/1E6);
if (!rows) {
taosCloseFile(&pFile);
return 0;
......@@ -162,14 +165,14 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres) {
return numOfRows;
}
static int shellDumpWebsocket(WS_RES *wres, char *fname, int *error_no, bool vertical) {
static int shellDumpWebsocket(WS_RES *wres, char *fname, int *error_no, bool vertical, double* pexecute_time) {
int numOfRows = 0;
if (fname != NULL) {
numOfRows = dumpWebsocketToFile(fname, wres);
numOfRows = dumpWebsocketToFile(fname, wres, pexecute_time);
} else if (vertical) {
numOfRows = verticalPrintWebsocket(wres);
numOfRows = verticalPrintWebsocket(wres, pexecute_time);
} else {
numOfRows = horizontalPrintWebsocket(wres);
numOfRows = horizontalPrintWebsocket(wres, pexecute_time);
}
*error_no = ws_errno(wres);
return numOfRows;
......@@ -225,6 +228,8 @@ void shellRunSingleCommandWebsocketImp(char *command) {
return;
}
double execute_time = ws_take_timing(res)/1E6;
if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
fprintf(stdout, "Database changed.\r\n\r\n");
fflush(stdout);
......@@ -236,22 +241,27 @@ void shellRunSingleCommandWebsocketImp(char *command) {
if (ws_is_update_query(res)) {
numOfRows = ws_affected_rows(res);
et = taosGetTimestampUs();
printf("Query Ok, %d of %d row(s) in database (%.6fs)\n", numOfRows, numOfRows,
(et - st)/1E6);
double total_time = (et - st)/1E3;
double net_time = total_time - (double)execute_time;
printf("Query Ok, %d of %d row(s) in database\n", numOfRows, numOfRows);
printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time);
} else {
int error_no = 0;
numOfRows = shellDumpWebsocket(res, fname, &error_no, printMode);
numOfRows = shellDumpWebsocket(res, fname, &error_no, printMode, &execute_time);
if (numOfRows < 0) {
ws_free_result(res);
return;
}
et = taosGetTimestampUs();
double total_time = (et - st) / 1E3;
double net_time = total_time - execute_time;
if (error_no == 0 && !shell.stop_query) {
printf("Query OK, %d row(s) in set (%.6fs)\n", numOfRows,
(et - st)/1E6);
printf("Query OK, %d row(s) in set\n", numOfRows);
printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time);
} else {
printf("Query interrupted, %d row(s) in set (%.6fs)\n", numOfRows,
(et - st)/1E6);
printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time);
}
}
printf("\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册