Skip to content

Commit

Permalink
Merge pull request #693 from taosdata/feat/math
Browse files Browse the repository at this point in the history
feat: adjust default test database time step
  • Loading branch information
gccgdb1234 authored Jul 25, 2023
2 parents 698d9c3 + c2d977e commit 77b3244
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
5 changes: 3 additions & 2 deletions example/insert_math.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@
"partial_col_num": 0,
"disorder_ratio": 0,
"disorder_range": 1000,
"timestamp_step": 10,
"timestamp_step": 1000,
"angle_step": 500,
"start_timestamp": "2020-10-01 00:00:00.000",
"sample_format": "csv",
"sample_file": "./sample.csv",
"use_sample_ts": "no",
"tags_file": "",
"columns": [
{ "type": "FLOAT", "name": "current", "fun": "1*sin(x)+10*random(15)"},
{ "type": "FLOAT", "name": "current", "fun": "3*sin(x)+10*random(2)"},
{ "type": "INT", "name": "voltage", "fun": "40*sin(x)+200*random(10)"},
{ "type": "FLOAT", "name": "phase", "fun": "1*sin(x)+1*random(3)"}
],
Expand Down
2 changes: 2 additions & 0 deletions inc/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ typedef unsigned __int32 uint32_t;
#define BENCH_INTERVAL \
"Insert interval for interlace mode in milliseconds, default is 0."
#define BENCH_STEP "Timestamp step in milliseconds, default is 1."
#define ANGLE_STEP "Angle step in milliseconds, default is 1."
#define BENCH_SUPPLEMENT \
"Supplementally insert data without create " \
"database and table, optional, default is off."
Expand Down Expand Up @@ -682,6 +683,7 @@ typedef struct SSuperTable_S {
uint64_t insert_interval;
uint64_t insertRows;
uint64_t timestamp_step;
uint64_t angle_step;
int64_t startTimestamp;
int64_t specifiedColumns;
char sampleFile[MAX_FILE_NAME_LEN];
Expand Down
7 changes: 4 additions & 3 deletions src/benchCommandOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ static void initStable() {

c1->min = 9;
c1->max = 10;
// fun = "1*sin(x)+10*random(15)"
// fun = "3*sin(x)+10*random(2)"
c1->funType = FUNTYPE_SIN;
c1->multiple = 1;
c1->random = 15;
c1->multiple = 3;
c1->random = 2;
c1->addend = 10;

c2->min = 110;
Expand Down Expand Up @@ -183,6 +183,7 @@ static void initStable() {

stbInfo->insert_interval = 0;
stbInfo->timestamp_step = 1;
stbInfo->angle_step = 1;
stbInfo->interlaceRows = 0;
stbInfo->childTblCount = DEFAULT_CHILDTABLES;
stbInfo->childTblLimit = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ static int generateRandDataSQL(SSuperTable *stbInfo, char *sampleDataBuf,
}
skip_sql:
*(sampleDataBuf + pos - 1) = 0;
angle += stbInfo->timestamp_step;
angle += stbInfo->timestamp_step/stbInfo->angle_step;
if (angle > 360) {
angle -= 360;
}
Expand Down
7 changes: 7 additions & 0 deletions src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) {
superTable->tcpTransfer = false;
superTable->childTblOffset = 0;
superTable->timestamp_step = 1;
superTable->angle_step = 1;
superTable->useSampleTs = false;
superTable->non_stop = false;
superTable->insertRows = 0;
Expand Down Expand Up @@ -819,6 +820,12 @@ static int getStableInfo(tools_cJSON *dbinfos, int index) {
superTable->timestamp_step = timestampStep->valueint;
}

tools_cJSON *angleStep =
tools_cJSON_GetObjectItem(stbInfo, "angle_step");
if (tools_cJSON_IsNumber(angleStep)) {
superTable->angle_step = timestampStep->valueint;
}

tools_cJSON *keepTrying =
tools_cJSON_GetObjectItem(stbInfo, "keep_trying");
if (tools_cJSON_IsNumber(keepTrying)) {
Expand Down
16 changes: 16 additions & 0 deletions src/benchSys.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ static struct argp_option bench_options[] = {
{"threads", 'T', "NUMBER", 0, BENCH_THREAD},
{"insert-interval", 'i', "NUMBER", 0, BENCH_INTERVAL},
{"time-step", 'S', "NUMBER", 0, BENCH_STEP},
{"angle-step", 'H', "NUMBER", 0, ANGLE_STEP},
{"start-timestamp", 's', "NUMBER", 0, BENCH_START_TIMESTAMP},
{"supplement-insert", 'U', 0, 0, BENCH_SUPPLEMENT},
{"interlace-rows", 'B', "NUMBER", 0, BENCH_INTERLACE},
Expand Down Expand Up @@ -392,6 +393,21 @@ int32_t benchParseSingleOpt(int32_t key, char* arg) {
}
break;

// angle step
case 'H':
if (!toolsIsStringNumber(arg)) {
errorPrintReqArg2(CUS_PROMPT"Benchmark", "H");
}

stbInfo->angle_step = atol(arg);
if (stbInfo->angle_step <= 0) {
errorPrint(
"Invalid -H: %s, will auto set to default(1)\n",
arg);
stbInfo->angle_step = 1;
}
break;

case 'B':
if (!toolsIsStringNumber(arg)) {
errorPrintReqArg2(CUS_PROMPT"Benchmark", "B");
Expand Down

0 comments on commit 77b3244

Please sign in to comment.