Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
40cb2f55
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
40cb2f55
编写于
6月 21, 2021
作者:
Z
zhaoyanggh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change performance test tool to optimize write test
上级
02f511bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
6 deletion
+78
-6
tests/comparisonTest/tdengine/tdengineTest.c
tests/comparisonTest/tdengine/tdengineTest.c
+78
-6
未找到文件。
tests/comparisonTest/tdengine/tdengineTest.c
浏览文件 @
40cb2f55
...
...
@@ -181,8 +181,8 @@ void writeDataImp(void *param) {
if
(
lastMachineid
!=
machineid
)
{
lastMachineid
=
machineid
;
sqlLen
+=
sprintf
(
sql
+
sqlLen
,
" dev%d
using devices tags(%d,'%s',%d)
values"
,
machineid
,
machineid
,
machinename
,
machinegroup
);
sqlLen
+=
sprintf
(
sql
+
sqlLen
,
" dev%d values"
,
machineid
);
}
sqlLen
+=
sprintf
(
sql
+
sqlLen
,
"(%"
PRId64
",%d,%f)"
,
timestamp
,
temperature
,
humidity
);
...
...
@@ -192,7 +192,8 @@ void writeDataImp(void *param) {
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
threadId
,
code
,
taos_errstr
(
taos
));
printf
(
"insert into dev%d values (%"
PRId64
",%d,%f)
\n
"
,
machineid
,
timestamp
,
temperature
,
humidity
);
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
threadId
,
code
,
taos_errstr
(
result
));
}
taos_free_result
(
result
);
...
...
@@ -210,6 +211,7 @@ void writeDataImp(void *param) {
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
// printf("insert into dev%d using devices tags(%d,'%s',%d) values (%" PRId64 ",%d,%f)",machineid, machineid, machinename, machinegroup, timestamp, temperature, humidity);
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
threadId
,
code
,
taos_errstr
(
taos
));
}
taos_free_result
(
result
);
...
...
@@ -246,7 +248,7 @@ void writeData() {
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table if not exists db.devices(ts timestamp, temperature int, humidity float) "
"create
s
table if not exists db.devices(ts timestamp, temperature int, humidity float) "
"tags(devid int, devname binary(16), devgroup int)"
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
...
...
@@ -254,6 +256,77 @@ void writeData() {
}
taos_free_result
(
result
);
//create tables before insert the data
result
=
taos_query
(
taos
,
"use db"
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
result
,
taos
);
}
taos_free_result
(
result
);
char
*
sql
=
calloc
(
1
,
8
*
1024
*
1024
);
int
sqlLen
=
0
;
int
lastMachineid
=
0
;
int
counter
=
0
;
int
totalRecords
=
0
;
for
(
int
i
=
0
;
i
<
arguments
.
filesNum
;
i
++
)
{
char
fileName
[
300
];
sprintf
(
fileName
,
"%s/testdata%d.csv"
,
arguments
.
dataDir
,
i
);
FILE
*
fp
=
fopen
(
fileName
,
"r"
);
if
(
fp
==
NULL
)
{
printf
(
"failed to open file %s
\n
"
,
fileName
);
exit
(
1
);
}
printf
(
"open file %s success
\n
"
,
fileName
);
char
*
line
=
NULL
;
size_t
len
=
0
;
while
(
!
feof
(
fp
))
{
free
(
line
);
line
=
NULL
;
len
=
0
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
break
;
if
(
strlen
(
line
)
<
10
)
continue
;
int
machineid
;
char
machinename
[
16
];
int
machinegroup
;
int64_t
timestamp
;
int
temperature
;
float
humidity
;
sscanf
(
line
,
"%d%s%d%"
PRId64
"%d%f"
,
&
machineid
,
machinename
,
&
machinegroup
,
&
timestamp
,
&
temperature
,
&
humidity
);
if
(
counter
==
0
)
{
sqlLen
=
sprintf
(
sql
,
"create table if not exists"
);
}
if
(
lastMachineid
!=
machineid
)
{
lastMachineid
=
machineid
;
sqlLen
+=
sprintf
(
sql
+
sqlLen
,
" dev%d using devices tags(%d,'%s',%d)"
,
machineid
,
machineid
,
machinename
,
machinegroup
);
}
counter
++
;
if
(
counter
>=
arguments
.
rowsPerRequest
)
{
result
=
taos_query
(
taos
,
sql
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"create table error:%d reason:%s
\n
"
,
code
,
taos_errstr
(
result
));
}
taos_free_result
(
result
);
totalRecords
+=
counter
;
counter
=
0
;
lastMachineid
=
-
1
;
sqlLen
=
0
;
}
}
fclose
(
fp
);
}
int64_t
st
=
getTimeStampMs
();
int
a
=
arguments
.
filesNum
/
arguments
.
clients
;
...
...
@@ -379,5 +452,4 @@ void readData() {
}
free
(
threads
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录