Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
31d5d302
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
31d5d302
编写于
4月 03, 2021
作者:
sangshuduo
提交者:
GitHub
4月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3636] <fix>: taosdemo disorder rework. (#5671)
Co-authored-by:
N
Shuduo Sang
<
sdsang@taosdata.com
>
上级
763a14c8
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
60 addition
and
45 deletion
+60
-45
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+60
-45
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
31d5d302
...
...
@@ -211,8 +211,8 @@ typedef struct SArguments_S {
int
num_of_tables
;
int
num_of_DPT
;
int
abort
;
int
disorderRatio
;
int
disorderRange
;
int
disorderRatio
;
// 0: no disorder, >0: x%
int
disorderRange
;
// ms or us by database precision
int
method_of_delete
;
char
**
arg_list
;
int64_t
totalInsertRows
;
...
...
@@ -247,7 +247,7 @@ typedef struct SSuperTable_S {
int
insertInterval
;
// insert interval, will override global insert interval
int64_t
insertRows
;
// 0: no limit
int
timeStampStep
;
char
startTimestamp
[
MAX_TB_NAME_SIZE
];
//
char
startTimestamp
[
MAX_TB_NAME_SIZE
];
char
sampleFormat
[
MAX_TB_NAME_SIZE
];
// csv, json
char
sampleFile
[
MAX_FILE_NAME_LEN
+
1
];
char
tagsFile
[
MAX_FILE_NAME_LEN
+
1
];
...
...
@@ -487,7 +487,7 @@ static int taosRandom()
return
number
;
}
#else
#else
// Not windows
static
void
setupForAnsiEscape
(
void
)
{}
static
void
resetAfterAnsiEscape
(
void
)
{
...
...
@@ -499,11 +499,15 @@ static void resetAfterAnsiEscape(void) {
static
int
taosRandom
()
{
srand
(
time
(
NULL
));
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
srand
(
tv
.
tv_usec
);
return
rand
();
}
#endif
#endif
// ifdef Windows
static
int
createDatabasesAndStables
();
static
void
createChildTables
();
...
...
@@ -676,7 +680,7 @@ static void printHelp() {
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-x"
,
indent
,
"Not insert only flag."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-y"
,
indent
,
"Default input yes for prompt."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-O"
,
indent
,
"Insert mode--0: In order,
>
0: disorder ratio. Default is in order."
);
"Insert mode--0: In order,
1 ~ 5
0: disorder ratio. Default is in order."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-R"
,
indent
,
"Out of order data's range, ms, default is 1000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-g"
,
indent
,
...
...
@@ -800,20 +804,21 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
strcpy
(
configDir
,
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
arguments
->
disorderRatio
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
disorderRatio
>
1
||
arguments
->
disorderRatio
<
0
)
{
if
(
arguments
->
disorderRatio
>
50
)
arguments
->
disorderRatio
=
50
;
if
(
arguments
->
disorderRatio
<
0
)
arguments
->
disorderRatio
=
0
;
}
else
if
(
arguments
->
disorderRatio
==
1
)
{
arguments
->
disorderRange
=
10
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"-R"
)
==
0
)
{
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
disorderRange
==
1
&&
(
arguments
->
disorderRange
>
50
||
arguments
->
disorderRange
<=
0
))
{
arguments
->
disorderRange
=
10
;
}
if
(
arguments
->
disorderRange
<
0
)
arguments
->
disorderRange
=
1000
;
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
arguments
->
replica
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
replica
>
3
||
arguments
->
replica
<
1
)
{
...
...
@@ -997,8 +1002,9 @@ static void selectAndGetResult(TAOS *taos, char *command, char* resultFileName)
taos_free_result
(
res
);
}
static
double
getCurrentTime
()
{
static
double
getCurrentTime
Us
()
{
struct
timeval
tv
;
if
(
gettimeofday
(
&
tv
,
NULL
)
!=
0
)
{
perror
(
"Failed to get current time in ms"
);
return
0
.
0
;
...
...
@@ -3669,6 +3675,12 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
cJSON
*
disorderRatio
=
cJSON_GetObjectItem
(
stbInfo
,
"disorder_ratio"
);
if
(
disorderRatio
&&
disorderRatio
->
type
==
cJSON_Number
)
{
if
(
disorderRatio
->
valueint
>
50
)
disorderRatio
->
valueint
=
50
;
if
(
disorderRatio
->
valueint
<
0
)
disorderRatio
->
valueint
=
0
;
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRatio
=
disorderRatio
->
valueint
;
}
else
if
(
!
disorderRatio
)
{
g_Dbs
.
db
[
i
].
superTbls
[
j
].
disorderRatio
=
0
;
...
...
@@ -4329,6 +4341,8 @@ static int32_t generateData(char *recBuf, char **data_type,
pstr
+=
sprintf
(
pstr
,
")"
);
verbosePrint
(
"%s() LN%d, recBuf:
\n\t
%s
\n
"
,
__func__
,
__LINE__
,
recBuf
);
return
(
int32_t
)
strlen
(
recBuf
);
}
...
...
@@ -4440,7 +4454,7 @@ static int generateDataTail(char *tableName, int32_t tableSeq,
pSamplePos
);
}
else
if
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
"rand"
,
strlen
(
"rand"
)))
{
int
rand_num
=
rand_tinyint
()
%
100
;
int
rand_num
=
taosRandom
()
%
100
;
if
(
0
!=
superTblInfo
->
disorderRatio
&&
rand_num
<
superTblInfo
->
disorderRatio
)
{
int64_t
d
=
startTime
...
...
@@ -4467,15 +4481,16 @@ static int generateDataTail(char *tableName, int32_t tableSeq,
len
+=
retLen
;
remainderBufLen
-=
retLen
;
}
else
{
int
rand_num
=
taosRandom
()
%
100
;
char
**
data_type
=
g_args
.
datatype
;
int
lenOfBinary
=
g_args
.
len_of_binary
;
int
rand_num
=
taosRandom
()
%
100
;
if
((
g_args
.
disorderRatio
!=
0
)
&&
(
rand_num
<
g_args
.
disorderRa
nge
))
{
&&
(
rand_num
<
g_args
.
disorderRa
tio
))
{
int64_t
d
=
startTime
+
DEFAULT_TIMESTAMP_STEP
*
k
-
taosRandom
()
%
1000000
+
rand_num
;
-
taosRandom
()
%
g_args
.
disorderRange
;
retLen
=
generateData
(
data
,
data_type
,
ncols_per_record
,
d
,
lenOfBinary
);
}
else
{
...
...
@@ -5024,7 +5039,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
int
rand_num
=
taosRandom
()
%
100
;
if
(
0
!=
winfo
->
superTblInfo
->
disorderRatio
&&
rand_num
<
winfo
->
superTblInfo
->
disorderRatio
)
{
int64_t
d
=
winfo
->
lastTs
-
taosRandom
()
%
1000000
+
rand_num
;
int64_t
d
=
winfo
->
lastTs
-
taosRandom
()
%
winfo
->
superTblInfo
->
disorderRange
;
generateRowData
(
data
,
d
,
winfo
->
superTblInfo
);
}
else
{
generateRowData
(
data
,
winfo
->
lastTs
+=
1000
,
winfo
->
superTblInfo
);
...
...
@@ -5116,7 +5131,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
start_time
=
1500000000000
;
}
double
start
=
getCurrentTime
();
double
start
=
getCurrentTime
Us
();
// read sample data from file first
if
((
superTblInfo
)
&&
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
...
...
@@ -5311,7 +5326,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if
(
cntDelay
==
0
)
cntDelay
=
1
;
avgDelay
=
(
double
)
totalDelay
/
cntDelay
;
double
end
=
getCurrentTime
();
double
end
=
getCurrentTime
Us
();
double
t
=
end
-
start
;
if
(
superTblInfo
)
{
...
...
@@ -5390,7 +5405,7 @@ static void *readTable(void *sarg) {
sprintf
(
command
,
"select %s from %s%d where ts>= %"
PRId64
,
aggreFunc
[
j
],
tb_prefix
,
i
,
sTime
);
double
t
=
getCurrentTime
();
double
t
=
getCurrentTime
Us
();
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
pSql
);
...
...
@@ -5406,7 +5421,7 @@ static void *readTable(void *sarg) {
count
++
;
}
t
=
getCurrentTime
()
-
t
;
t
=
getCurrentTime
Us
()
-
t
;
totalT
+=
t
;
taos_free_result
(
pSql
);
...
...
@@ -5465,7 +5480,7 @@ static void *readMetric(void *sarg) {
printf
(
"Where condition: %s
\n
"
,
condition
);
fprintf
(
fp
,
"%s
\n
"
,
command
);
double
t
=
getCurrentTime
();
double
t
=
getCurrentTime
Us
();
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
pSql
);
...
...
@@ -5481,7 +5496,7 @@ static void *readMetric(void *sarg) {
while
(
taos_fetch_row
(
pSql
)
!=
NULL
)
{
count
++
;
}
t
=
getCurrentTime
()
-
t
;
t
=
getCurrentTime
Us
()
-
t
;
fprintf
(
fp
,
"| Speed: %12.2f(per s) | Latency: %.4f(ms) |
\n
"
,
num_of_tables
*
num_of_DPT
/
t
,
t
*
1000
);
...
...
@@ -5535,9 +5550,9 @@ static int insertTestProcess() {
double
end
;
// create child tables
start
=
getCurrentTime
();
start
=
getCurrentTime
Us
();
createChildTables
();
end
=
getCurrentTime
();
end
=
getCurrentTime
Us
();
if
(
g_totalChildTables
>
0
)
{
printf
(
"Spent %.4f seconds to create %d tables with %d thread(s)
\n\n
"
,
...
...
@@ -5549,7 +5564,7 @@ static int insertTestProcess() {
taosMsleep
(
1000
);
// create sub threads for inserting data
//start = getCurrentTime();
//start = getCurrentTime
Us
();
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
if
(
g_Dbs
.
use_metric
)
{
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
...
...
@@ -5574,7 +5589,7 @@ static int insertTestProcess() {
NULL
);
}
}
//end = getCurrentTime();
//end = getCurrentTime
Us
();
//int64_t totalInsertRows = 0;
//int64_t totalAffectedRows = 0;
...
...
@@ -6395,7 +6410,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
char
*
line
=
NULL
;
size_t
line_len
=
0
;
double
t
=
getCurrentTime
();
double
t
=
getCurrentTime
Us
();
while
((
read_len
=
tgetline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
if
(
read_len
>=
MAX_SQL_SIZE
)
continue
;
...
...
@@ -6426,7 +6441,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
cmd_len
=
0
;
}
t
=
getCurrentTime
()
-
t
;
t
=
getCurrentTime
Us
()
-
t
;
printf
(
"run %s took %.6f second(s)
\n\n
"
,
sqlFile
,
t
);
tmfree
(
cmd
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录