Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5f72c178
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看板
提交
5f72c178
编写于
1月 06, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
cb67c500
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
26 deletion
+27
-26
tests/test/c/create_table.c
tests/test/c/create_table.c
+27
-26
未找到文件。
tests/test/c/create_table.c
浏览文件 @
5f72c178
...
...
@@ -25,15 +25,15 @@
char
dbName
[
32
]
=
"db"
;
char
stbName
[
64
]
=
"st"
;
int32_t
numOfThreads
=
1
;
int
32
_t
numOfTables
=
200000
;
int
64
_t
numOfTables
=
200000
;
int32_t
createTable
=
1
;
int32_t
insertData
=
0
;
int32_t
batchNum
=
100
;
int32_t
numOfVgroups
=
2
;
typedef
struct
{
int
32
_t
tableBeginIndex
;
int
32
_t
tableEndIndex
;
int
64
_t
tableBeginIndex
;
int
64
_t
tableEndIndex
;
int32_t
threadIndex
;
char
dbName
[
32
];
char
stbName
[
64
];
...
...
@@ -58,7 +58,7 @@ int32_t main(int32_t argc, char *argv[]) {
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
calloc
(
numOfThreads
,
sizeof
(
SThreadInfo
));
int
32
_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
int
64
_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
numOfTables
=
numOfTablesPerThread
*
numOfThreads
;
for
(
int32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
pInfo
[
i
].
tableBeginIndex
=
i
*
numOfTablesPerThread
;
...
...
@@ -84,9 +84,10 @@ int32_t main(int32_t argc, char *argv[]) {
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
}
pPrint
(
"%s total %d tables, %.1f tables/second, threads:%d %s"
,
GREEN
,
numOfTables
,
createTableSpeed
,
numOfThreads
,
NC
);
pPrint
(
"%s total %d tables, %.1f rows/second, threads:%d %s"
,
GREEN
,
numOfTables
,
insertDataSpeed
,
numOfThreads
,
NC
);
pPrint
(
"%s total %"
PRId64
" tables, %.1f tables/second, threads:%d %s"
,
GREEN
,
numOfTables
,
createTableSpeed
,
numOfThreads
,
NC
);
pPrint
(
"%s total %"
PRId64
" tables, %.1f rows/second, threads:%d %s"
,
GREEN
,
numOfTables
,
insertDataSpeed
,
numOfThreads
,
NC
);
pthread_attr_destroy
(
&
thattr
);
free
(
pInfo
);
...
...
@@ -132,24 +133,24 @@ void createDbAndStb() {
taos_close
(
con
);
}
void
printCreateProgress
(
SThreadInfo
*
pInfo
,
int
32
_t
t
)
{
void
printCreateProgress
(
SThreadInfo
*
pInfo
,
int
64
_t
t
)
{
int64_t
endMs
=
taosGetTimestampMs
();
int
32
_t
totalTables
=
t
-
pInfo
->
tableBeginIndex
;
int
64
_t
totalTables
=
t
-
pInfo
->
tableBeginIndex
;
float
seconds
=
(
endMs
-
pInfo
->
startMs
)
/
1000
.
0
;
float
speed
=
totalTables
/
seconds
;
pInfo
->
createTableSpeed
=
speed
;
pPrint
(
"thread:%d, %
d tables created, time:%.2f sec, speed:%.1f tables/second, "
,
pInfo
->
threadIndex
,
totalTables
,
seconds
,
speed
);
pPrint
(
"thread:%d, %
"
PRId64
" tables created, time:%.2f sec, speed:%.1f tables/second, "
,
pInfo
->
threadIndex
,
totalTables
,
seconds
,
speed
);
}
void
printInsertProgress
(
SThreadInfo
*
pInfo
,
int
32
_t
t
)
{
void
printInsertProgress
(
SThreadInfo
*
pInfo
,
int
64
_t
t
)
{
int64_t
endMs
=
taosGetTimestampMs
();
int
32
_t
totalTables
=
t
-
pInfo
->
tableBeginIndex
;
int
64
_t
totalTables
=
t
-
pInfo
->
tableBeginIndex
;
float
seconds
=
(
endMs
-
pInfo
->
startMs
)
/
1000
.
0
;
float
speed
=
totalTables
/
seconds
;
pInfo
->
insertDataSpeed
=
speed
;
pPrint
(
"thread:%d, %
d rows inserted, time:%.2f sec, speed:%.1f rows/second, "
,
pInfo
->
threadIndex
,
totalTables
,
seconds
,
speed
);
pPrint
(
"thread:%d, %
"
PRId64
" rows inserted, time:%.2f sec, speed:%.1f rows/second, "
,
pInfo
->
threadIndex
,
totalTables
,
seconds
,
speed
);
}
void
*
threadFunc
(
void
*
param
)
{
...
...
@@ -169,19 +170,19 @@ void *threadFunc(void *param) {
if
(
createTable
)
{
pInfo
->
startMs
=
taosGetTimestampMs
();
for
(
int
32
_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int
32
_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
for
(
int
64
_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int
64
_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
batch
=
MIN
(
batch
,
batchNum
);
int32_t
len
=
sprintf
(
qstr
,
"create table"
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
len
+=
sprintf
(
qstr
+
len
,
" t%
d using %s tags(%d
)"
,
t
+
i
,
stbName
,
t
+
i
);
len
+=
sprintf
(
qstr
+
len
,
" t%
"
PRId64
" using %s tags(%"
PRId64
"
)"
,
t
+
i
,
stbName
,
t
+
i
);
}
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to create table t%
d
, reason:%s"
,
t
,
tstrerror
(
code
));
pError
(
"failed to create table t%
"
PRId64
"
, reason:%s"
,
t
,
tstrerror
(
code
));
}
taos_free_result
(
pSql
);
...
...
@@ -195,19 +196,19 @@ void *threadFunc(void *param) {
if
(
insertData
)
{
pInfo
->
startMs
=
taosGetTimestampMs
();
for
(
int
32
_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int
32
_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
for
(
int
64
_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int
64
_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%
d values(now, %d
)"
,
t
+
i
,
t
+
i
);
len
+=
sprintf
(
qstr
+
len
,
" t%
"
PRId64
" values(now, %"
PRId64
"
)"
,
t
+
i
,
t
+
i
);
}
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to insert table t%
d
, reason:%s"
,
t
,
tstrerror
(
code
));
pError
(
"failed to insert table t%
"
PRId64
"
, reason:%s"
,
t
,
tstrerror
(
code
));
}
taos_free_result
(
pSql
);
...
...
@@ -237,7 +238,7 @@ void printHelp() {
printf
(
"%s%s
\n
"
,
indent
,
"-t"
);
printf
(
"%s%s%s%d
\n
"
,
indent
,
indent
,
"numOfThreads, default is "
,
numOfThreads
);
printf
(
"%s%s
\n
"
,
indent
,
"-n"
);
printf
(
"%s%s%s%
d
\n
"
,
indent
,
indent
,
"numOfTables, default is "
,
numOfTables
);
printf
(
"%s%s%s%
"
PRId64
"
\n
"
,
indent
,
indent
,
"numOfTables, default is "
,
numOfTables
);
printf
(
"%s%s
\n
"
,
indent
,
"-v"
);
printf
(
"%s%s%s%d
\n
"
,
indent
,
indent
,
"numOfVgroups, default is "
,
numOfVgroups
);
printf
(
"%s%s
\n
"
,
indent
,
"-a"
);
...
...
@@ -264,7 +265,7 @@ void parseArgument(int32_t argc, char *argv[]) {
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
numOfThreads
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
numOfTables
=
ato
i
(
argv
[
++
i
]);
numOfTables
=
ato
ll
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
numOfVgroups
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
...
...
@@ -280,7 +281,7 @@ void parseArgument(int32_t argc, char *argv[]) {
pPrint
(
"%s dbName:%s %s"
,
GREEN
,
dbName
,
NC
);
pPrint
(
"%s stbName:%s %s"
,
GREEN
,
stbName
,
NC
);
pPrint
(
"%s configDir:%s %s"
,
GREEN
,
configDir
,
NC
);
pPrint
(
"%s numOfTables:%
d
%s"
,
GREEN
,
numOfTables
,
NC
);
pPrint
(
"%s numOfTables:%
"
PRId64
"
%s"
,
GREEN
,
numOfTables
,
NC
);
pPrint
(
"%s numOfThreads:%d %s"
,
GREEN
,
numOfThreads
,
NC
);
pPrint
(
"%s numOfVgroups:%d %s"
,
GREEN
,
numOfVgroups
,
NC
);
pPrint
(
"%s createTable:%d %s"
,
GREEN
,
createTable
,
NC
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录