Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
572cb584
T
TDengine
项目概览
taosdata
/
TDengine
11 个月 前同步成功
通知
1179
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
572cb584
编写于
1月 06, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
create table test
上级
33a80e69
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
17 deletion
+46
-17
tests/test/c/create_table.c
tests/test/c/create_table.c
+46
-17
未找到文件。
tests/test/c/create_table.c
浏览文件 @
572cb584
...
...
@@ -28,7 +28,7 @@ int32_t numOfThreads = 1;
int32_t
numOfTables
=
10000
;
int32_t
createTable
=
1
;
int32_t
insertData
=
0
;
int32_t
batchNum
=
1
0
;
int32_t
batchNum
=
1
;
int32_t
numOfVgroups
=
2
;
typedef
struct
{
...
...
@@ -39,6 +39,7 @@ typedef struct {
char
stbName
[
64
];
float
createTableSpeed
;
float
insertDataSpeed
;
int64_t
startMs
;
pthread_t
thread
;
}
SThreadInfo
;
...
...
@@ -130,6 +131,26 @@ void createDbAndStb() {
taos_close
(
con
);
}
void
printCreateProgress
(
SThreadInfo
*
pInfo
,
int32_t
t
)
{
int64_t
endMs
=
taosGetTimestampMs
();
int32_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
);
}
void
printInsertProgress
(
SThreadInfo
*
pInfo
,
int32_t
t
)
{
int64_t
endMs
=
taosGetTimestampMs
();
int32_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
);
}
void
*
threadFunc
(
void
*
param
)
{
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
char
*
qstr
=
malloc
(
2000
*
1000
);
...
...
@@ -146,7 +167,7 @@ void *threadFunc(void *param) {
taos_free_result
(
pSql
);
if
(
createTable
)
{
int64_t
startMs
=
taosGetTimestampMs
();
pInfo
->
startMs
=
taosGetTimestampMs
();
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int32_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
batch
=
MIN
(
batch
,
batchNum
);
...
...
@@ -155,38 +176,46 @@ void *threadFunc(void *param) {
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
len
+=
sprintf
(
qstr
+
len
,
" t%d using %s tags(%d)"
,
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
));
}
taos_free_result
(
pSql
);
if
(
t
%
1000
==
0
)
{
printCreateProgress
(
pInfo
,
t
);
}
t
+=
(
batch
-
1
);
}
int64_t
endMs
=
taosGetTimestampMs
();
int32_t
totalTables
=
pInfo
->
tableEndIndex
-
pInfo
->
tableBeginIndex
;
float
seconds
=
(
endMs
-
startMs
)
/
1000
.
0
;
float
speed
=
totalTables
/
seconds
;
pInfo
->
createTableSpeed
=
speed
;
pPrint
(
"thread:%d, time:%.2f sec, speed:%.1f tables/second, "
,
pInfo
->
threadIndex
,
seconds
,
speed
);
printCreateProgress
(
pInfo
,
pInfo
->
tableEndIndex
);
}
if
(
insertData
)
{
int64_t
startMs
=
taosGetTimestampMs
();
pInfo
->
startMs
=
taosGetTimestampMs
();
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
sprintf
(
qstr
,
"insert into %s%d values(now, 1)"
,
stbName
,
t
);
int32_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
);
}
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to
create table %s%d, reason:%s"
,
stbName
,
t
,
tstrerror
(
code
));
pError
(
"failed to
insert table t%d, reason:%s"
,
t
,
tstrerror
(
code
));
}
taos_free_result
(
pSql
);
if
(
t
%
100000
==
0
)
{
printInsertProgress
(
pInfo
,
t
);
}
t
+=
(
batch
-
1
);
}
int64_t
endMs
=
taosGetTimestampMs
();
int32_t
totalTables
=
pInfo
->
tableEndIndex
-
pInfo
->
tableBeginIndex
;
float
seconds
=
(
endMs
-
startMs
)
/
1000
.
0
;
float
speed
=
totalTables
/
seconds
;
pInfo
->
insertDataSpeed
=
speed
;
pPrint
(
"thread:%d, time:%.2f sec, speed:%.1f rows/second, "
,
pInfo
->
threadIndex
,
seconds
,
speed
);
printInsertProgress
(
pInfo
,
pInfo
->
tableEndIndex
);
}
taos_close
(
con
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录