Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c019bc98
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看板
提交
c019bc98
编写于
7月 13, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update tdengineTest.c for performace test
上级
85dc9973
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
21 deletion
+41
-21
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-0
tests/comparisonTest/tdengine/CMakeLists.txt
tests/comparisonTest/tdengine/CMakeLists.txt
+12
-0
tests/comparisonTest/tdengine/tdengineTest.c
tests/comparisonTest/tdengine/tdengineTest.c
+28
-21
未找到文件。
tests/CMakeLists.txt
浏览文件 @
c019bc98
...
...
@@ -12,3 +12,4 @@ SET(CMAKE_VERBOSE_MAKEFILE ON)
ADD_SUBDIRECTORY
(
examples/c
)
ADD_SUBDIRECTORY
(
tsim
)
ADD_SUBDIRECTORY
(
test/c
)
ADD_SUBDIRECTORY
(
comparisonTest/tdengine
)
tests/comparisonTest/tdengine/CMakeLists.txt
0 → 100644
浏览文件 @
c019bc98
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/util/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/common/inc
)
INCLUDE_DIRECTORIES
(
${
TD_OS_DIR
}
/inc
)
IF
((
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
))
add_executable
(
tdengineTest tdengineTest.c
)
target_link_libraries
(
tdengineTest taos_static tutil common pthread
)
ENDIF
()
tests/comparisonTest/tdengine/tdengineTest.c
浏览文件 @
c019bc98
...
...
@@ -7,6 +7,7 @@
#include <time.h>
#include <pthread.h>
#include <sys/time.h>
#include <inttypes.h>
typedef
struct
{
char
sql
[
256
];
...
...
@@ -123,19 +124,21 @@ void writeDataImp(void *param) {
if
(
taos
==
NULL
)
taos_error
(
taos
);
int
code
=
taos_query
(
taos
,
"use db"
);
TAOS_RES
*
result
=
taos_query
(
taos
,
"use db"
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
}
taos_free_result
(
result
);
char
sql
[
65000
]
;
char
*
sql
=
calloc
(
1
,
8
*
1024
*
1024
)
;
int
sqlLen
=
0
;
int
lastMachineid
=
0
;
int
counter
=
0
;
int
totalRecords
=
0
;
for
(
int
j
=
pThread
->
sID
;
j
<=
pThread
->
eID
;
j
++
)
{
char
fileName
[
256
];
char
fileName
[
300
];
sprintf
(
fileName
,
"%s/testdata%d.csv"
,
arguments
.
dataDir
,
j
);
FILE
*
fp
=
fopen
(
fileName
,
"r"
);
...
...
@@ -162,7 +165,7 @@ void writeDataImp(void *param) {
int64_t
timestamp
;
int
temperature
;
float
humidity
;
sscanf
(
line
,
"%d%s%d%
lld
%d%f"
,
&
machineid
,
machinename
,
&
machinegroup
,
&
timestamp
,
&
temperature
,
&
humidity
);
sscanf
(
line
,
"%d%s%d%
"
PRId64
"
%d%f"
,
&
machineid
,
machinename
,
&
machinegroup
,
&
timestamp
,
&
temperature
,
&
humidity
);
if
(
counter
==
0
)
{
sqlLen
=
sprintf
(
sql
,
"insert into"
);
...
...
@@ -174,14 +177,16 @@ void writeDataImp(void *param) {
machineid
,
machineid
,
machinename
,
machinegroup
);
}
sqlLen
+=
sprintf
(
sql
+
sqlLen
,
"(%
lld
,%d,%f)"
,
timestamp
,
temperature
,
humidity
);
sqlLen
+=
sprintf
(
sql
+
sqlLen
,
"(%
"
PRId64
"
,%d,%f)"
,
timestamp
,
temperature
,
humidity
);
counter
++
;
if
(
counter
>=
arguments
.
rowsPerRequest
)
{
int
code
=
taos_query
(
taos
,
sql
);
TAOS_RES
*
result
=
taos_query
(
taos
,
sql
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
pi
d
,
code
,
taos_errstr
(
taos
));
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
threadI
d
,
code
,
taos_errstr
(
taos
));
}
taos_free_result
(
result
);
totalRecords
+=
counter
;
counter
=
0
;
...
...
@@ -194,15 +199,18 @@ void writeDataImp(void *param) {
}
if
(
counter
>
0
)
{
int
code
=
taos_query
(
taos
,
sql
);
TAOS_RES
*
result
=
taos_query
(
taos
,
sql
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
pi
d
,
code
,
taos_errstr
(
taos
));
printf
(
"thread:%d error:%d reason:%s
\n
"
,
pThread
->
threadI
d
,
code
,
taos_errstr
(
taos
));
}
taos_free_result
(
result
);
totalRecords
+=
counter
;
}
__sync_fetch_and_add
(
&
statis
.
totalRows
,
totalRecords
);
free
(
sql
);
}
void
writeData
()
{
...
...
@@ -215,19 +223,23 @@ void writeData() {
taos_init
();
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
int
code
=
taos_query
(
taos
,
"create database if not exists db"
);
TAOS_RES
*
result
=
taos_query
(
taos
,
"create database if not exists db"
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
}
taos_free_result
(
result
);
code
=
taos_query
(
taos
,
"create table if not exists db.devices(ts timestamp, temperature int, humidity float) "
"tags(devid int, devname binary(16), devgroup int)"
);
result
=
taos_query
(
taos
,
"create 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
)
{
taos_error
(
taos
);
}
taos_free_result
(
result
);
int64_t
st
=
getTimeStampMs
();
...
...
@@ -292,17 +304,12 @@ void readData() {
int64_t
st
=
getTimeStampMs
();
int
code
=
taos_query
(
taos
,
line
);
TAOS_RES
*
result
=
taos_query
(
taos
,
line
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
}
void
*
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
printf
(
"failed to get result, reason:%s
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
TAOS_ROW
row
;
int
rows
=
0
;
//int num_fields = taos_field_count(taos);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录