Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
16049c87
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看板
提交
16049c87
编写于
7月 18, 2020
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support query clients.
上级
3fb51717
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
21 deletion
+55
-21
tests/comparisonTest/tdengine/q5.txt
tests/comparisonTest/tdengine/q5.txt
+1
-0
tests/comparisonTest/tdengine/tdengineTest.c
tests/comparisonTest/tdengine/tdengineTest.c
+54
-21
未找到文件。
tests/comparisonTest/tdengine/q5.txt
0 → 100644
浏览文件 @
16049c87
select * from db.devices;
tests/comparisonTest/tdengine/tdengineTest.c
浏览文件 @
16049c87
...
...
@@ -13,8 +13,9 @@ typedef struct {
char
sql
[
256
];
char
dataDir
[
256
];
int
filesNum
;
int
writeC
lients
;
int
c
lients
;
int
rowsPerRequest
;
int
write
;
}
ProArgs
;
typedef
struct
{
...
...
@@ -41,7 +42,7 @@ int main(int argc, char *argv[]) {
statis
.
totalRows
=
0
;
parseArg
(
argc
,
argv
);
if
(
arguments
.
write
Clients
>
0
)
{
if
(
arguments
.
write
)
{
writeData
();
}
else
{
readData
();
...
...
@@ -52,7 +53,7 @@ void parseArg(int argc, char *argv[]) {
strcpy
(
arguments
.
sql
,
"./sqlCmd.txt"
);
strcpy
(
arguments
.
dataDir
,
"./testdata"
);
arguments
.
filesNum
=
2
;
arguments
.
writeClients
=
0
;
arguments
.
clients
=
1
;
arguments
.
rowsPerRequest
=
100
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
...
...
@@ -83,12 +84,12 @@ void parseArg(int argc, char *argv[]) {
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-
writeC
lients"
)
==
0
)
{
else
if
(
strcmp
(
argv
[
i
],
"-
c
lients"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
.
writeC
lients
=
atoi
(
argv
[
++
i
]);
arguments
.
c
lients
=
atoi
(
argv
[
++
i
]);
}
else
{
fprintf
(
stderr
,
"'-
writeClients' requires a parameter, default:%d
\n
"
,
arguments
.
writeC
lients
);
fprintf
(
stderr
,
"'-
clients' requires a parameter, default:%d
\n
"
,
arguments
.
c
lients
);
exit
(
EXIT_FAILURE
);
}
}
...
...
@@ -101,6 +102,9 @@ void parseArg(int argc, char *argv[]) {
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
arguments
.
write
=
1
;
}
}
}
...
...
@@ -215,7 +219,7 @@ void writeDataImp(void *param) {
void
writeData
()
{
printf
(
"write data
\n
"
);
printf
(
"----
writeClients: %d
\n
"
,
arguments
.
writeC
lients
);
printf
(
"----
clients: %d
\n
"
,
arguments
.
c
lients
);
printf
(
"---- dataDir: %s
\n
"
,
arguments
.
dataDir
);
printf
(
"---- numOfFiles: %d
\n
"
,
arguments
.
filesNum
);
printf
(
"---- rowsPerRequest: %d
\n
"
,
arguments
.
rowsPerRequest
);
...
...
@@ -243,12 +247,12 @@ void writeData() {
int64_t
st
=
getTimeStampMs
();
int
a
=
arguments
.
filesNum
/
arguments
.
writeC
lients
;
int
b
=
arguments
.
filesNum
%
arguments
.
writeC
lients
;
int
a
=
arguments
.
filesNum
/
arguments
.
c
lients
;
int
b
=
arguments
.
filesNum
%
arguments
.
c
lients
;
int
last
=
0
;
ThreadObj
*
threads
=
calloc
((
size_t
)
arguments
.
writeC
lients
,
sizeof
(
ThreadObj
));
for
(
int
i
=
0
;
i
<
arguments
.
writeC
lients
;
++
i
)
{
ThreadObj
*
threads
=
calloc
((
size_t
)
arguments
.
c
lients
,
sizeof
(
ThreadObj
));
for
(
int
i
=
0
;
i
<
arguments
.
c
lients
;
++
i
)
{
ThreadObj
*
pthread
=
threads
+
i
;
pthread_attr_t
thattr
;
pthread
->
threadId
=
i
+
1
;
...
...
@@ -264,7 +268,7 @@ void writeData() {
pthread_create
(
&
pthread
->
pid
,
&
thattr
,
(
void
*
(
*
)(
void
*
))
writeDataImp
,
pthread
);
}
for
(
int
i
=
0
;
i
<
arguments
.
writeC
lients
;
i
++
)
{
for
(
int
i
=
0
;
i
<
arguments
.
c
lients
;
i
++
)
{
pthread_join
(
threads
[
i
].
pid
,
NULL
);
}
...
...
@@ -272,17 +276,15 @@ void writeData() {
float
seconds
=
(
float
)
elapsed
/
1000
;
float
rs
=
(
float
)
statis
.
totalRows
/
seconds
;
free
(
threads
);
printf
(
"---- Spent %f seconds to insert %ld records, speed: %f Rows/Second
\n
"
,
seconds
,
statis
.
totalRows
,
rs
);
}
void
readData
()
{
printf
(
"read data
\n
"
);
printf
(
"---- sql: %s
\n
"
,
arguments
.
sql
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
void
readDataImp
(
void
*
param
)
{
ThreadObj
*
pThread
=
(
ThreadObj
*
)
param
;
printf
(
"Thread %d
\n
"
,
pThread
->
threadId
);
FILE
*
fp
=
fopen
(
arguments
.
sql
,
"r"
);
if
(
fp
==
NULL
)
{
printf
(
"failed to open file %s
\n
"
,
arguments
.
sql
);
...
...
@@ -290,6 +292,10 @@ void readData() {
}
printf
(
"open file %s success
\n
"
,
arguments
.
sql
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
char
*
line
=
NULL
;
size_t
len
=
0
;
while
(
!
feof
(
fp
))
{
...
...
@@ -325,9 +331,36 @@ void readData() {
int64_t
elapsed
=
getTimeStampMs
()
-
st
;
float
seconds
=
(
float
)
elapsed
/
1000
;
printf
(
"---- Spent %f seconds to
query: %s"
,
seconds
,
line
);
printf
(
"---- Spent %f seconds to
retrieve %d records, Thread:%d query: %s
\n
"
,
seconds
,
rows
,
pThread
->
threadId
,
line
);
}
fclose
(
fp
);
}
void
readData
()
{
printf
(
"read data
\n
"
);
printf
(
"---- sql: %s
\n
"
,
arguments
.
sql
);
printf
(
"---- clients: %d
\n
"
,
arguments
.
clients
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
ThreadObj
*
threads
=
calloc
((
size_t
)
arguments
.
clients
,
sizeof
(
ThreadObj
));
for
(
int
i
=
0
;
i
<
arguments
.
clients
;
++
i
)
{
ThreadObj
*
pthread
=
threads
+
i
;
pthread_attr_t
thattr
;
pthread
->
threadId
=
i
+
1
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
pthread_create
(
&
pthread
->
pid
,
&
thattr
,
(
void
*
(
*
)(
void
*
))
readDataImp
,
pthread
);
}
for
(
int
i
=
0
;
i
<
arguments
.
clients
;
i
++
)
{
pthread_join
(
threads
[
i
].
pid
,
NULL
);
}
free
(
threads
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录