create_table.c 14.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#define _DEFAULT_SOURCE
#include "os.h"
S
Shengliang Guan 已提交
18
#include "taos.h"
19
#include "taoserror.h"
S
Shengliang Guan 已提交
20
#include "ulog.h"
21 22 23 24 25

#define GREEN "\033[1;32m"
#define NC "\033[0m"

char    dbName[32] = "db";
S
Shengliang Guan 已提交
26
char    stbName[64] = "st";
S
Shengliang Guan 已提交
27
int32_t numOfThreads = 1;
S
Shengliang Guan 已提交
28
int64_t numOfTables = 200000;
P
plum-lihui 已提交
29
int64_t startOffset = 0;
S
Shengliang Guan 已提交
30 31
int32_t createTable = 1;
int32_t insertData = 0;
P
plum-lihui 已提交
32 33
int32_t batchNumOfTbl = 100;
int32_t batchNumOfRow = 1;
S
Shengliang Guan 已提交
34
int32_t numOfVgroups = 2;
L
lihui 已提交
35
int32_t showTablesFlag = 0;
P
plum-lihui 已提交
36 37
int32_t queryFlag = 0;

S
Shengliang Guan 已提交
38
int64_t startTimestamp = 1640966400000;  // 2020-01-01 00:00:00.000
39 40

typedef struct {
S
Shengliang Guan 已提交
41 42
  int64_t   tableBeginIndex;
  int64_t   tableEndIndex;
43 44
  int32_t   threadIndex;
  char      dbName[32];
S
Shengliang Guan 已提交
45
  char      stbName[64];
46
  float     createTableSpeed;
S
Shengliang Guan 已提交
47
  float     insertDataSpeed;
S
Shengliang Guan 已提交
48
  int64_t   startMs;
L
lihui 已提交
49 50
  int64_t   maxDelay;
  int64_t   minDelay;
51 52 53
  pthread_t thread;
} SThreadInfo;

54 55 56
// void  parseArgument(int32_t argc, char *argv[]);
// void *threadFunc(void *param);
// void  createDbAndStb();
57

S
Shengliang Guan 已提交
58
void createDbAndStb() {
59 60
  pPrint("start to create db and stable");
  char qstr[64000];
S
Shengliang Guan 已提交
61

62 63
  TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
  if (con == NULL) {
L
lihui 已提交
64
    pError("failed to connect to DB, reason:%s", taos_errstr(NULL));
65 66 67
    exit(1);
  }

S
Shengliang Guan 已提交
68
  sprintf(qstr, "create database if not exists %s vgroups %d", dbName, numOfVgroups);
L
lihui 已提交
69 70
  TAOS_RES *pRes = taos_query(con, qstr);
  int32_t   code = taos_errno(pRes);
71
  if (code != 0) {
72 73
    pError("failed to create database:%s, sql:%s, code:%d reason:%s", dbName, qstr, taos_errno(pRes),
           taos_errstr(pRes));
74 75
    exit(0);
  }
L
lihui 已提交
76
  taos_free_result(pRes);
77 78

  sprintf(qstr, "use %s", dbName);
L
lihui 已提交
79 80
  pRes = taos_query(con, qstr);
  code = taos_errno(pRes);
81
  if (code != 0) {
L
lihui 已提交
82
    pError("failed to use db, code:%d reason:%s", taos_errno(pRes), taos_errstr(pRes));
83 84
    exit(0);
  }
L
lihui 已提交
85
  taos_free_result(pRes);
86

S
Shengliang Guan 已提交
87
  sprintf(qstr, "create table if not exists %s (ts timestamp, i int) tags (j bigint)", stbName);
L
lihui 已提交
88 89
  pRes = taos_query(con, qstr);
  code = taos_errno(pRes);
S
Shengliang Guan 已提交
90
  if (code != 0) {
S
Shengliang Guan 已提交
91
    pError("failed to create stable, code:%d reason:%s", taos_errno(pRes), taos_errstr(pRes));
S
Shengliang Guan 已提交
92 93
    exit(0);
  }
L
lihui 已提交
94
  taos_free_result(pRes);
S
Shengliang Guan 已提交
95

96 97 98
  taos_close(con);
}

S
Shengliang Guan 已提交
99
void printCreateProgress(SThreadInfo *pInfo, int64_t t) {
S
Shengliang Guan 已提交
100
  int64_t endMs = taosGetTimestampMs();
S
Shengliang Guan 已提交
101
  int64_t totalTables = t - pInfo->tableBeginIndex;
S
Shengliang Guan 已提交
102 103 104
  float   seconds = (endMs - pInfo->startMs) / 1000.0;
  float   speed = totalTables / seconds;
  pInfo->createTableSpeed = speed;
S
Shengliang Guan 已提交
105 106
  pPrint("thread:%d, %" PRId64 " tables created, time:%.2f sec, speed:%.1f tables/second, ", pInfo->threadIndex,
         totalTables, seconds, speed);
S
Shengliang Guan 已提交
107 108
}

S
Shengliang Guan 已提交
109
void printInsertProgress(SThreadInfo *pInfo, int64_t t) {
S
Shengliang Guan 已提交
110
  int64_t endMs = taosGetTimestampMs();
S
Shengliang Guan 已提交
111
  int64_t totalTables = t - pInfo->tableBeginIndex;
S
Shengliang Guan 已提交
112 113 114
  float   seconds = (endMs - pInfo->startMs) / 1000.0;
  float   speed = totalTables / seconds;
  pInfo->insertDataSpeed = speed;
S
Shengliang Guan 已提交
115 116
  pPrint("thread:%d, %" PRId64 " rows inserted, time:%.2f sec, speed:%.1f rows/second, ", pInfo->threadIndex,
         totalTables, seconds, speed);
S
Shengliang Guan 已提交
117 118
}

L
lihui 已提交
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
static int64_t getResult(TAOS_RES *tres) {
  TAOS_ROW row = taos_fetch_row(tres);
  if (row == NULL) {
    return 0;
  }

  int         num_fields = taos_num_fields(tres);
  TAOS_FIELD *fields = taos_fetch_fields(tres);
  int         precision = taos_result_precision(tres);

  int64_t numOfRows = 0;
  do {
    numOfRows++;
    row = taos_fetch_row(tres);
  } while (row != NULL);

  return numOfRows;
}

138
void showTables() {
L
lihui 已提交
139
  pPrint("start to show tables");
140
  char qstr[128];
L
lihui 已提交
141 142 143 144 145 146 147

  TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
  if (con == NULL) {
    pError("failed to connect to DB, reason:%s", taos_errstr(NULL));
    exit(1);
  }

148
  snprintf(qstr, 128, "use %s", dbName);
L
lihui 已提交
149
  TAOS_RES *pRes = taos_query(con, qstr);
150
  int       code = taos_errno(pRes);
L
lihui 已提交
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
  if (code != 0) {
    pError("failed to use db, code:%d reason:%s", taos_errno(pRes), taos_errstr(pRes));
    exit(1);
  }
  taos_free_result(pRes);

  sprintf(qstr, "show tables");
  pRes = taos_query(con, qstr);
  code = taos_errno(pRes);
  if (code != 0) {
    pError("failed to show tables, code:%d reason:%s", taos_errno(pRes), taos_errstr(pRes));
    exit(0);
  }

  int64_t totalTableNum = getResult(pRes);
  taos_free_result(pRes);

168
  pPrint("%s database: %s, total %" PRId64 " tables %s", GREEN, dbName, totalTableNum, NC);
L
lihui 已提交
169 170 171 172

  taos_close(con);
}

173 174
void *threadFunc(void *param) {
  SThreadInfo *pInfo = (SThreadInfo *)param;
P
plum-lihui 已提交
175
  char        *qstr = malloc(batchNumOfTbl * batchNumOfRow * 128);
S
Shengliang Guan 已提交
176
  int32_t      code = 0;
177 178 179

  TAOS *con = taos_connect(NULL, "root", "taosdata", NULL, 0);
  if (con == NULL) {
L
lihui 已提交
180
    pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(NULL));
181 182 183
    exit(1);
  }

S
Shengliang Guan 已提交
184 185
  pPrint("====before thread:%d, table range: %" PRId64 " - %" PRId64 "\n", pInfo->threadIndex, pInfo->tableBeginIndex,
         pInfo->tableEndIndex);
186

P
plum-lihui 已提交
187
  pInfo->tableBeginIndex += startOffset;
S
Shengliang Guan 已提交
188
  pInfo->tableEndIndex += startOffset;
H
Haojun Liao 已提交
189

S
Shengliang Guan 已提交
190 191
  pPrint("====after thread:%d, table range: %" PRId64 " - %" PRId64 "\n", pInfo->threadIndex, pInfo->tableBeginIndex,
         pInfo->tableEndIndex);
H
Haojun Liao 已提交
192

193
  sprintf(qstr, "use %s", pInfo->dbName);
L
lihui 已提交
194 195 196
  TAOS_RES *pRes = taos_query(con, qstr);
  taos_free_result(pRes);

S
Shengliang Guan 已提交
197
  if (createTable) {
L
lihui 已提交
198 199 200
    int64_t curMs = 0;
    int64_t beginMs = taosGetTimestampMs();
    pInfo->startMs = beginMs;
201
    int64_t t = pInfo->tableBeginIndex;
L
lihui 已提交
202
    for (; t <= pInfo->tableEndIndex;) {
203 204
      // int64_t batch = (pInfo->tableEndIndex - t);
      // batch = MIN(batch, batchNum);
S
Shengliang Guan 已提交
205 206

      int32_t len = sprintf(qstr, "create table");
P
plum-lihui 已提交
207
      for (int32_t i = 0; i < batchNumOfTbl;) {
L
lihui 已提交
208
        len += sprintf(qstr + len, " %s_t%" PRId64 " using %s tags(%" PRId64 ")", stbName, t, stbName, t);
209 210
        t++;
        i++;
L
lihui 已提交
211
        if (t > pInfo->tableEndIndex) {
212 213
          break;
        }
S
Shengliang Guan 已提交
214
      }
S
Shengliang Guan 已提交
215

216
      int64_t   startTs = taosGetTimestampUs();
L
lihui 已提交
217 218
      TAOS_RES *pRes = taos_query(con, qstr);
      code = taos_errno(pRes);
S
Shengliang Guan 已提交
219
      if (code != 0) {
P
plum-lihui 已提交
220
        pError("failed to create table reason:%s, sql: %s", tstrerror(code), qstr);
S
TD-1415  
Shengliang Guan 已提交
221
      }
L
lihui 已提交
222
      taos_free_result(pRes);
223 224 225 226
      int64_t endTs = taosGetTimestampUs();
      int64_t delay = endTs - startTs;
      // printf("==== %"PRId64" -  %"PRId64", %"PRId64"\n", startTs, endTs, delay);
      if (delay > pInfo->maxDelay) pInfo->maxDelay = delay;
L
lihui 已提交
227 228
      if (delay < pInfo->minDelay) pInfo->minDelay = delay;

229 230 231 232
      curMs = taosGetTimestampMs();
      if (curMs - beginMs > 10000) {
        beginMs = curMs;
        // printf("==== tableBeginIndex: %"PRId64", t: %"PRId64"\n", pInfo->tableBeginIndex, t);
S
Shengliang Guan 已提交
233 234
        printCreateProgress(pInfo, t);
      }
S
TD-1415  
Shengliang Guan 已提交
235
    }
L
lihui 已提交
236
    printCreateProgress(pInfo, t);
S
Shengliang Guan 已提交
237 238 239
  }

  if (insertData) {
L
lihui 已提交
240
    int64_t curMs = 0;
241
    int64_t beginMs = taosGetTimestampMs();
P
plum-lihui 已提交
242 243 244 245 246
    pInfo->startMs = beginMs;
    int64_t t = pInfo->tableBeginIndex;
    for (; t <= pInfo->tableEndIndex;) {
      // int64_t batch = (pInfo->tableEndIndex - t);
      // batch = MIN(batch, batchNum);
L
lihui 已提交
247

P
plum-lihui 已提交
248
      int32_t len = sprintf(qstr, "insert into ");
S
Shengliang Guan 已提交
249

P
plum-lihui 已提交
250
      for (int32_t i = 0; i < batchNumOfTbl;) {
S
Shengliang Guan 已提交
251
        int64_t ts = startTimestamp;
P
plum-lihui 已提交
252 253
        len += sprintf(qstr + len, "%s_t%" PRId64 " values ", stbName, t);
        for (int32_t j = 0; j < batchNumOfRow; j++) {
S
Shengliang Guan 已提交
254
          len += sprintf(qstr + len, "(%" PRId64 ", 6666) ", ts++);
P
plum-lihui 已提交
255
        }
S
Shengliang Guan 已提交
256

P
plum-lihui 已提交
257 258 259 260 261
        t++;
        i++;
        if (t > pInfo->tableEndIndex) {
          break;
        }
S
Shengliang Guan 已提交
262
      }
S
Shengliang Guan 已提交
263

P
plum-lihui 已提交
264
      int64_t   startTs = taosGetTimestampUs();
L
lihui 已提交
265 266
      TAOS_RES *pRes = taos_query(con, qstr);
      code = taos_errno(pRes);
P
plum-lihui 已提交
267 268
      if ((code != 0) && (code != TSDB_CODE_RPC_AUTH_REQUIRED)) {
        pError("failed to insert %s_t%" PRId64 ", reason:%s", stbName, t, tstrerror(code));
S
TD-1415  
Shengliang Guan 已提交
269
      }
L
lihui 已提交
270
      taos_free_result(pRes);
P
plum-lihui 已提交
271 272 273 274 275
      int64_t endTs = taosGetTimestampUs();
      int64_t delay = endTs - startTs;
      // printf("==== %"PRId64" -  %"PRId64", %"PRId64"\n", startTs, endTs, delay);
      if (delay > pInfo->maxDelay) pInfo->maxDelay = delay;
      if (delay < pInfo->minDelay) pInfo->minDelay = delay;
S
Shengliang Guan 已提交
276

L
lihui 已提交
277
      curMs = taosGetTimestampMs();
278
      if (curMs - beginMs > 10000) {
P
plum-lihui 已提交
279 280
        beginMs = curMs;
        // printf("==== tableBeginIndex: %"PRId64", t: %"PRId64"\n", pInfo->tableBeginIndex, t);
S
Shengliang Guan 已提交
281 282
        printInsertProgress(pInfo, t);
      }
283
    }
P
plum-lihui 已提交
284
    printInsertProgress(pInfo, t);
285 286 287
  }

  taos_close(con);
S
Shengliang Guan 已提交
288
  free(qstr);
289 290 291 292 293 294 295 296 297 298 299 300
  return 0;
}

void printHelp() {
  char indent[10] = "        ";
  printf("Used to test the performance while create table\n");

  printf("%s%s\n", indent, "-c");
  printf("%s%s%s%s\n", indent, indent, "Configuration directory, default is ", configDir);
  printf("%s%s\n", indent, "-d");
  printf("%s%s%s%s\n", indent, indent, "The name of the database to be created, default is ", dbName);
  printf("%s%s\n", indent, "-s");
S
Shengliang Guan 已提交
301
  printf("%s%s%s%s\n", indent, indent, "The name of the super table to be created, default is ", stbName);
302 303 304
  printf("%s%s\n", indent, "-t");
  printf("%s%s%s%d\n", indent, indent, "numOfThreads, default is ", numOfThreads);
  printf("%s%s\n", indent, "-n");
S
Shengliang Guan 已提交
305
  printf("%s%s%s%" PRId64 "\n", indent, indent, "numOfTables, default is ", numOfTables);
P
plum-lihui 已提交
306
  printf("%s%s\n", indent, "-g");
P
plum-lihui 已提交
307
  printf("%s%s%s%" PRId64 "\n", indent, indent, "startOffset, default is ", startOffset);
S
Shengliang Guan 已提交
308 309 310 311 312 313 314
  printf("%s%s\n", indent, "-v");
  printf("%s%s%s%d\n", indent, indent, "numOfVgroups, default is ", numOfVgroups);
  printf("%s%s\n", indent, "-a");
  printf("%s%s%s%d\n", indent, indent, "createTable, default is ", createTable);
  printf("%s%s\n", indent, "-i");
  printf("%s%s%s%d\n", indent, indent, "insertData, default is ", insertData);
  printf("%s%s\n", indent, "-b");
P
plum-lihui 已提交
315
  printf("%s%s%s%d\n", indent, indent, "batchNumOfTbl, default is ", batchNumOfTbl);
L
lihui 已提交
316 317
  printf("%s%s\n", indent, "-w");
  printf("%s%s%s%d\n", indent, indent, "showTablesFlag, default is ", showTablesFlag);
P
plum-lihui 已提交
318 319 320 321
  printf("%s%s\n", indent, "-q");
  printf("%s%s%s%d\n", indent, indent, "queryFlag, default is ", queryFlag);
  printf("%s%s\n", indent, "-l");
  printf("%s%s%s%d\n", indent, indent, "batchNumOfRow, default is ", batchNumOfRow);
S
Shengliang Guan 已提交
322

323 324 325
  exit(EXIT_SUCCESS);
}

S
Shengliang Guan 已提交
326 327
void parseArgument(int32_t argc, char *argv[]) {
  for (int32_t i = 1; i < argc; i++) {
328 329 330 331 332 333 334 335
    if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
      printHelp();
      exit(0);
    } else if (strcmp(argv[i], "-d") == 0) {
      strcpy(dbName, argv[++i]);
    } else if (strcmp(argv[i], "-c") == 0) {
      strcpy(configDir, argv[++i]);
    } else if (strcmp(argv[i], "-s") == 0) {
S
Shengliang Guan 已提交
336
      strcpy(stbName, argv[++i]);
337 338 339
    } else if (strcmp(argv[i], "-t") == 0) {
      numOfThreads = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-n") == 0) {
S
Shengliang Guan 已提交
340
      numOfTables = atoll(argv[++i]);
P
plum-lihui 已提交
341
    } else if (strcmp(argv[i], "-g") == 0) {
P
plum-lihui 已提交
342
      startOffset = atoll(argv[++i]);
L
lihui 已提交
343
    } else if (strcmp(argv[i], "-v") == 0) {
S
Shengliang Guan 已提交
344 345 346 347 348 349
      numOfVgroups = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-a") == 0) {
      createTable = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-i") == 0) {
      insertData = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-b") == 0) {
P
plum-lihui 已提交
350 351 352
      batchNumOfTbl = atoi(argv[++i]);
    } else if (strcmp(argv[i], "-l") == 0) {
      batchNumOfRow = atoi(argv[++i]);
L
lihui 已提交
353 354
    } else if (strcmp(argv[i], "-w") == 0) {
      showTablesFlag = atoi(argv[++i]);
P
plum-lihui 已提交
355 356
    } else if (strcmp(argv[i], "-q") == 0) {
      queryFlag = atoi(argv[++i]);
357
    } else {
S
Shengliang Guan 已提交
358
      pPrint("%s unknow para: %s %s", GREEN, argv[++i], NC);
359 360 361 362
    }
  }

  pPrint("%s dbName:%s %s", GREEN, dbName, NC);
S
Shengliang Guan 已提交
363
  pPrint("%s stbName:%s %s", GREEN, stbName, NC);
364
  pPrint("%s configDir:%s %s", GREEN, configDir, NC);
S
Shengliang Guan 已提交
365
  pPrint("%s numOfTables:%" PRId64 " %s", GREEN, numOfTables, NC);
P
plum-lihui 已提交
366
  pPrint("%s startOffset:%" PRId64 " %s", GREEN, startOffset, NC);
367
  pPrint("%s numOfThreads:%d %s", GREEN, numOfThreads, NC);
S
Shengliang Guan 已提交
368 369 370
  pPrint("%s numOfVgroups:%d %s", GREEN, numOfVgroups, NC);
  pPrint("%s createTable:%d %s", GREEN, createTable, NC);
  pPrint("%s insertData:%d %s", GREEN, insertData, NC);
P
plum-lihui 已提交
371 372
  pPrint("%s batchNumOfTbl:%d %s", GREEN, batchNumOfTbl, NC);
  pPrint("%s batchNumOfRow:%d %s", GREEN, batchNumOfRow, NC);
L
lihui 已提交
373
  pPrint("%s showTablesFlag:%d %s", GREEN, showTablesFlag, NC);
P
plum-lihui 已提交
374
  pPrint("%s queryFlag:%d %s", GREEN, queryFlag, NC);
S
Shengliang Guan 已提交
375

376 377
  pPrint("%s start create table performace test %s", GREEN, NC);
}
L
lihui 已提交
378 379 380 381 382

int32_t main(int32_t argc, char *argv[]) {
  parseArgument(argc, argv);

  if (showTablesFlag) {
383 384
    showTables();
    return 0;
L
lihui 已提交
385
  }
386

P
plum-lihui 已提交
387
  if (queryFlag) {
S
Shengliang Guan 已提交
388
    // selectRowsFromTable();
P
plum-lihui 已提交
389 390
    return 0;
  }
L
lihui 已提交
391

P
plum-lihui 已提交
392 393 394
  if (createTable) {
    createDbAndStb();
  }
S
Shengliang Guan 已提交
395 396 397

  pPrint("%d threads are spawned to create %" PRId64 " tables, offset is %" PRId64 " ", numOfThreads, numOfTables,
         startOffset);
L
lihui 已提交
398 399 400 401 402 403

  pthread_attr_t thattr;
  pthread_attr_init(&thattr);
  pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE);
  SThreadInfo *pInfo = (SThreadInfo *)calloc(numOfThreads, sizeof(SThreadInfo));

404 405
  // int64_t numOfTablesPerThread = numOfTables / numOfThreads;
  // numOfTables = numOfTablesPerThread * numOfThreads;
L
lihui 已提交
406 407 408 409

  if (numOfThreads < 1) {
    numOfThreads = 1;
  }
410

L
lihui 已提交
411 412
  int64_t a = numOfTables / numOfThreads;
  if (a < 1) {
413 414
    numOfThreads = numOfTables;
    a = 1;
L
lihui 已提交
415
  }
416

L
lihui 已提交
417 418 419 420 421 422
  int64_t b = 0;
  b = numOfTables % numOfThreads;

  int64_t tableFrom = 0;
  for (int32_t i = 0; i < numOfThreads; ++i) {
    pInfo[i].tableBeginIndex = tableFrom;
P
plum-lihui 已提交
423
    pInfo[i].tableEndIndex = (i < b ? tableFrom + a : tableFrom + a - 1);
L
lihui 已提交
424 425
    tableFrom = pInfo[i].tableEndIndex + 1;
    pInfo[i].threadIndex = i;
426
    pInfo[i].minDelay = INT64_MAX;
L
lihui 已提交
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
    strcpy(pInfo[i].dbName, dbName);
    strcpy(pInfo[i].stbName, stbName);
    pthread_create(&(pInfo[i].thread), &thattr, threadFunc, (void *)(pInfo + i));
  }

  taosMsleep(300);
  for (int32_t i = 0; i < numOfThreads; i++) {
    pthread_join(pInfo[i].thread, NULL);
  }

  int64_t maxDelay = 0;
  int64_t minDelay = INT64_MAX;

  float createTableSpeed = 0;
  for (int32_t i = 0; i < numOfThreads; ++i) {
    createTableSpeed += pInfo[i].createTableSpeed;

    if (pInfo[i].maxDelay > maxDelay) maxDelay = pInfo[i].maxDelay;
445
    if (pInfo[i].minDelay < minDelay) minDelay = pInfo[i].minDelay;
L
lihui 已提交
446 447 448 449 450 451 452
  }

  float insertDataSpeed = 0;
  for (int32_t i = 0; i < numOfThreads; ++i) {
    insertDataSpeed += pInfo[i].insertDataSpeed;
  }

P
plum-lihui 已提交
453 454
  if (createTable) {
    pPrint("%s total %" PRId64 " tables, %.1f tables/second, threads:%d, maxDelay: %" PRId64 "us, minDelay: %" PRId64
S
Shengliang Guan 已提交
455 456
           "us %s",
           GREEN, numOfTables, createTableSpeed, numOfThreads, maxDelay, minDelay, NC);
P
plum-lihui 已提交
457
  }
L
lihui 已提交
458 459

  if (insertData) {
460 461
    pPrint("%s total %" PRId64 " tables, %.1f rows/second, threads:%d %s", GREEN, numOfTables, insertDataSpeed,
           numOfThreads, NC);
L
lihui 已提交
462 463 464 465 466
  }

  pthread_attr_destroy(&thattr);
  free(pInfo);
}