Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bc1d8f6a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bc1d8f6a
编写于
1月 20, 2022
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[modify insert]
上级
2b6fe8e2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
22 deletion
+65
-22
tests/test/c/create_table.c
tests/test/c/create_table.c
+65
-22
未找到文件。
tests/test/c/create_table.c
浏览文件 @
bc1d8f6a
...
...
@@ -28,9 +28,14 @@ int32_t numOfThreads = 1;
int64_t
numOfTables
=
200000
;
int32_t
createTable
=
1
;
int32_t
insertData
=
0
;
int32_t
batchNum
=
100
;
int32_t
batchNumOfTbl
=
100
;
int32_t
batchNumOfRow
=
1
;
int32_t
numOfVgroups
=
2
;
int32_t
showTablesFlag
=
0
;
int32_t
queryFlag
=
0
;
int64_t
startTimestamp
=
1640966400000
;
// 2020-01-01 00:00:00.000
typedef
struct
{
int64_t
tableBeginIndex
;
...
...
@@ -167,7 +172,7 @@ void showTables() {
void
*
threadFunc
(
void
*
param
)
{
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
char
*
qstr
=
malloc
(
2000
*
1000
);
char
*
qstr
=
malloc
(
batchNumOfTbl
*
batchNumOfRow
*
128
);
int32_t
code
=
0
;
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -192,7 +197,7 @@ void *threadFunc(void *param) {
// batch = MIN(batch, batchNum);
int32_t
len
=
sprintf
(
qstr
,
"create table"
);
for
(
int32_t
i
=
0
;
i
<
batchNum
;)
{
for
(
int32_t
i
=
0
;
i
<
batchNum
OfTbl
;)
{
len
+=
sprintf
(
qstr
+
len
,
" %s_t%"
PRId64
" using %s tags(%"
PRId64
")"
,
stbName
,
t
,
stbName
,
t
);
t
++
;
i
++
;
...
...
@@ -205,7 +210,7 @@ void *threadFunc(void *param) {
TAOS_RES
*
pRes
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pRes
);
if
((
code
!=
0
)
&&
(
code
!=
TSDB_CODE_RPC_AUTH_REQUIRED
))
{
pError
(
"failed to create table t%"
PRId64
",
code: %d, reason:%s"
,
t
,
code
,
tstrerror
(
code
));
pError
(
"failed to create table t%"
PRId64
",
reason:%s"
,
t
,
tstrerror
(
code
));
}
taos_free_result
(
pRes
);
int64_t
endTs
=
taosGetTimestampUs
();
...
...
@@ -227,31 +232,49 @@ void *threadFunc(void *param) {
if
(
insertData
)
{
int64_t
curMs
=
0
;
int64_t
beginMs
=
taosGetTimestampMs
();
pInfo
->
startMs
=
beginMs
;
int64_t
t
=
pInfo
->
tableBeginIndex
;
for
(;
t
<=
pInfo
->
tableEndIndex
;)
{
// int64_t batch = (pInfo->tableEndIndex - t);
// batch = MIN(batch, batchNum);
pInfo
->
startMs
=
taosGetTimestampMs
();
for
(
int64_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int64_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
batch
=
MIN
(
batch
,
batchNum
);
int32_t
len
=
sprintf
(
qstr
,
"insert into"
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
len
+=
sprintf
(
qstr
+
len
,
" t%"
PRId64
" values(now, %"
PRId64
")"
,
t
+
i
,
t
+
i
);
}
int32_t
len
=
sprintf
(
qstr
,
"insert into "
);
for
(
int32_t
i
=
0
;
i
<
batchNumOfTbl
;)
{
int64_t
ts
=
startTimestamp
;
len
+=
sprintf
(
qstr
+
len
,
"%s_t%"
PRId64
" values "
,
stbName
,
t
);
for
(
int32_t
j
=
0
;
j
<
batchNumOfRow
;
j
++
)
{
len
+=
sprintf
(
qstr
+
len
,
"(%"
PRId64
", 6666) "
,
ts
++
);
}
t
++
;
i
++
;
if
(
t
>
pInfo
->
tableEndIndex
)
{
break
;
}
}
int64_t
startTs
=
taosGetTimestampUs
();
TAOS_RES
*
pRes
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
)
{
pError
(
"failed to insert
table t%"
PRId64
", reason:%s"
,
t
,
tstrerror
(
code
));
if
(
(
code
!=
0
)
&&
(
code
!=
TSDB_CODE_RPC_AUTH_REQUIRED
)
)
{
pError
(
"failed to insert
%s_t%"
PRId64
", reason:%s"
,
stbName
,
t
,
tstrerror
(
code
));
}
taos_free_result
(
pRes
);
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
;
curMs
=
taosGetTimestampMs
();
if
(
curMs
-
beginMs
>
10000
)
{
beginMs
=
curMs
;
// printf("==== tableBeginIndex: %"PRId64", t: %"PRId64"\n", pInfo->tableBeginIndex, t);
printInsertProgress
(
pInfo
,
t
);
}
t
+=
(
batch
-
1
);
}
printInsertProgress
(
pInfo
,
pInfo
->
tableEndIndex
);
printInsertProgress
(
pInfo
,
t
);
}
taos_close
(
con
);
...
...
@@ -280,9 +303,13 @@ void printHelp() {
printf
(
"%s%s
\n
"
,
indent
,
"-i"
);
printf
(
"%s%s%s%d
\n
"
,
indent
,
indent
,
"insertData, default is "
,
insertData
);
printf
(
"%s%s
\n
"
,
indent
,
"-b"
);
printf
(
"%s%s%s%d
\n
"
,
indent
,
indent
,
"batchNum
, default is "
,
batchNum
);
printf
(
"%s%s%s%d
\n
"
,
indent
,
indent
,
"batchNum
OfTbl, default is "
,
batchNumOfTbl
);
printf
(
"%s%s
\n
"
,
indent
,
"-w"
);
printf
(
"%s%s%s%d
\n
"
,
indent
,
indent
,
"showTablesFlag, default is "
,
showTablesFlag
);
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
);
exit
(
EXIT_SUCCESS
);
}
...
...
@@ -309,10 +336,15 @@ void parseArgument(int32_t argc, char *argv[]) {
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
)
{
insertData
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
batchNum
=
atoi
(
argv
[
++
i
]);
batchNumOfTbl
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
batchNumOfRow
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
showTablesFlag
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-q"
)
==
0
)
{
queryFlag
=
atoi
(
argv
[
++
i
]);
}
else
{
pPrint
(
"%s unknow para: %s %s"
,
GREEN
,
argv
[
++
i
],
NC
);
}
}
...
...
@@ -324,8 +356,10 @@ void parseArgument(int32_t argc, char *argv[]) {
pPrint
(
"%s numOfVgroups:%d %s"
,
GREEN
,
numOfVgroups
,
NC
);
pPrint
(
"%s createTable:%d %s"
,
GREEN
,
createTable
,
NC
);
pPrint
(
"%s insertData:%d %s"
,
GREEN
,
insertData
,
NC
);
pPrint
(
"%s batchNum:%d %s"
,
GREEN
,
batchNum
,
NC
);
pPrint
(
"%s batchNumOfTbl:%d %s"
,
GREEN
,
batchNumOfTbl
,
NC
);
pPrint
(
"%s batchNumOfRow:%d %s"
,
GREEN
,
batchNumOfRow
,
NC
);
pPrint
(
"%s showTablesFlag:%d %s"
,
GREEN
,
showTablesFlag
,
NC
);
pPrint
(
"%s queryFlag:%d %s"
,
GREEN
,
queryFlag
,
NC
);
pPrint
(
"%s start create table performace test %s"
,
GREEN
,
NC
);
}
...
...
@@ -338,8 +372,15 @@ int32_t main(int32_t argc, char *argv[]) {
return
0
;
}
createDbAndStb
();
if
(
queryFlag
)
{
//selectRowsFromTable();
return
0
;
}
if
(
createTable
)
{
createDbAndStb
();
}
pPrint
(
"%d threads are spawned to create %"
PRId64
" tables"
,
numOfThreads
,
numOfTables
);
pthread_attr_t
thattr
;
...
...
@@ -396,9 +437,11 @@ int32_t main(int32_t argc, char *argv[]) {
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
}
pPrint
(
"%s total %"
PRId64
" tables, %.1f tables/second, threads:%d, maxDelay: %"
PRId64
"us, minDelay: %"
PRId64
if
(
createTable
)
{
pPrint
(
"%s total %"
PRId64
" tables, %.1f tables/second, threads:%d, maxDelay: %"
PRId64
"us, minDelay: %"
PRId64
"us %s"
,
GREEN
,
numOfTables
,
createTableSpeed
,
numOfThreads
,
maxDelay
,
minDelay
,
NC
);
}
if
(
insertData
)
{
pPrint
(
"%s total %"
PRId64
" tables, %.1f rows/second, threads:%d %s"
,
GREEN
,
numOfTables
,
insertDataSpeed
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录