Skip to content

Commit

Permalink
Merge pull request #692 from taosdata/feat/math
Browse files Browse the repository at this point in the history
test: calculate angle according with timestamp and step
  • Loading branch information
gccgdb1234 committed Jul 24, 2023
2 parents 738f519 + 3e0446b commit 698d9c3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/benchData.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static int generateRandDataSQL(SSuperTable *stbInfo, char *sampleDataBuf,
int lenOfOneRow, BArray * fields, int64_t loop,
bool tag) {

int angle = 0; // 0 ~ 360
int angle = stbInfo->startTimestamp % 360; // 0 ~ 360
for (int64_t k = 0; k < loop; ++k) {
int64_t pos = k * lenOfOneRow;
int fieldsSize = fields->size;
Expand Down Expand Up @@ -726,10 +726,9 @@ static int generateRandDataSQL(SSuperTable *stbInfo, char *sampleDataBuf,
}
skip_sql:
*(sampleDataBuf + pos - 1) = 0;
angle += 1;
angle += stbInfo->timestamp_step;
if (angle > 360) {
// 360 is a circle
angle = 0;
angle -= 360;
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,21 @@ uint8_t parseFuns(char* funValue, float* multiple, int32_t* addend, int32_t* ran
return FUNTYPE_NONE;
}

if(strlen(funValue) > 100) {
size_t len = strlen(funValue);
if(len > 100) {
return FUNTYPE_NONE;
}

//parse format 10*sin(x) + 100 * random(5)
char value[128];
strcpy(value, funValue);
size_t n = 0;
for (size_t i = 0; i < len; i++) {
if (funValue[i] != ' ') {
value[n++] = funValue[i];
}
}
// set end
value[n] = 0;

// multiple
char* key1 = strstr(value, "*");
Expand Down

0 comments on commit 698d9c3

Please sign in to comment.