Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
83dfa155
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
83dfa155
编写于
11月 12, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
schemaless performance test remove restriction
上级
7fd66c21
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
12 deletion
+19
-12
tests/examples/c/schemaless.c
tests/examples/c/schemaless.c
+19
-12
未找到文件。
tests/examples/c/schemaless.c
浏览文件 @
83dfa155
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include <time.h>
#include <time.h>
#include <unistd.h>
#include <unistd.h>
#define MAX_THREAD_LINE_BATCHES 1024
bool
verbose
=
false
;
void
printThreadId
(
pthread_t
id
,
char
*
buf
)
void
printThreadId
(
pthread_t
id
,
char
*
buf
)
{
{
...
@@ -31,7 +31,7 @@ typedef struct {
...
@@ -31,7 +31,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
TAOS
*
taos
;
TAOS
*
taos
;
int
numBatches
;
int
numBatches
;
SThreadLinesBatch
batches
[
MAX_THREAD_LINE_BATCHES
]
;
SThreadLinesBatch
*
batches
;
int64_t
costTime
;
int64_t
costTime
;
}
SThreadInsertArgs
;
}
SThreadInsertArgs
;
...
@@ -41,12 +41,12 @@ static void* insertLines(void* args) {
...
@@ -41,12 +41,12 @@ static void* insertLines(void* args) {
printThreadId
(
pthread_self
(),
tidBuf
);
printThreadId
(
pthread_self
(),
tidBuf
);
for
(
int
i
=
0
;
i
<
insertArgs
->
numBatches
;
++
i
)
{
for
(
int
i
=
0
;
i
<
insertArgs
->
numBatches
;
++
i
)
{
SThreadLinesBatch
*
batch
=
insertArgs
->
batches
+
i
;
SThreadLinesBatch
*
batch
=
insertArgs
->
batches
+
i
;
printf
(
"%s, thread: 0x%s
\n
"
,
"begin taos_insert_lines"
,
tidBuf
);
if
(
verbose
)
printf
(
"%s, thread: 0x%s
\n
"
,
"begin taos_insert_lines"
,
tidBuf
);
int64_t
begin
=
getTimeInUs
();
int64_t
begin
=
getTimeInUs
();
int32_t
code
=
taos_insert_lines
(
insertArgs
->
taos
,
batch
->
lines
,
batch
->
numLines
);
int32_t
code
=
taos_insert_lines
(
insertArgs
->
taos
,
batch
->
lines
,
batch
->
numLines
);
int64_t
end
=
getTimeInUs
();
int64_t
end
=
getTimeInUs
();
insertArgs
->
costTime
+=
end
-
begin
;
insertArgs
->
costTime
+=
end
-
begin
;
printf
(
"code: %d, %s. time used:%"
PRId64
", thread: 0x%s
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
,
tidBuf
);
if
(
verbose
)
printf
(
"code: %d, %s. time used:%"
PRId64
", thread: 0x%s
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
,
tidBuf
);
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -88,6 +88,7 @@ int32_t getLineTemplate(char* lineTemplate, int templateLen, int numFields) {
...
@@ -88,6 +88,7 @@ int32_t getLineTemplate(char* lineTemplate, int templateLen, int numFields) {
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
int
numThreads
=
8
;
int
numThreads
=
8
;
int
maxBatchesPerThread
=
1024
;
int
numSuperTables
=
1
;
int
numSuperTables
=
1
;
int
numChildTables
=
256
;
int
numChildTables
=
256
;
...
@@ -97,7 +98,7 @@ int main(int argc, char* argv[]) {
...
@@ -97,7 +98,7 @@ int main(int argc, char* argv[]) {
int
maxLinesPerBatch
=
16384
;
int
maxLinesPerBatch
=
16384
;
int
opt
;
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
"s:c:r:f:t:
m:h
"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"s:c:r:f:t:
b:hv
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
's'
:
case
's'
:
numSuperTables
=
atoi
(
optarg
);
numSuperTables
=
atoi
(
optarg
);
...
@@ -114,15 +115,18 @@ int main(int argc, char* argv[]) {
...
@@ -114,15 +115,18 @@ int main(int argc, char* argv[]) {
case
't'
:
case
't'
:
numThreads
=
atoi
(
optarg
);
numThreads
=
atoi
(
optarg
);
break
;
break
;
case
'
m
'
:
case
'
b
'
:
maxLinesPerBatch
=
atoi
(
optarg
);
maxLinesPerBatch
=
atoi
(
optarg
);
break
;
break
;
case
'v'
:
verbose
=
true
;
break
;
case
'h'
:
case
'h'
:
fprintf
(
stderr
,
"Usage: %s -s supertable -c childtable -r rows -f fields -t threads -
m maxlines_per_batch
\n
"
,
fprintf
(
stderr
,
"Usage: %s -s supertable -c childtable -r rows -f fields -t threads -
b maxlines_per_batch -v
\n
"
,
argv
[
0
]);
argv
[
0
]);
exit
(
0
);
exit
(
0
);
default:
/* '?' */
default:
/* '?' */
fprintf
(
stderr
,
"Usage: %s -s supertable -c childtable -r rows -f fields -t threads -
m maxlines_per_batch
\n
"
,
fprintf
(
stderr
,
"Usage: %s -s supertable -c childtable -r rows -f fields -t threads -
b maxlines_per_batch -v
\n
"
,
argv
[
0
]);
argv
[
0
]);
exit
(
-
1
);
exit
(
-
1
);
}
}
...
@@ -140,10 +144,7 @@ int main(int argc, char* argv[]) {
...
@@ -140,10 +144,7 @@ int main(int argc, char* argv[]) {
exit
(
1
);
exit
(
1
);
}
}
if
(
numThreads
*
MAX_THREAD_LINE_BATCHES
*
maxLinesPerBatch
<
numSuperTables
*
numChildTables
*
numRowsPerChildTable
)
{
maxBatchesPerThread
=
(
numSuperTables
*
numChildTables
*
numRowsPerChildTable
)
/
(
numThreads
*
maxLinesPerBatch
)
+
1
;
printf
(
"too many rows to be handle by threads with %d batches"
,
MAX_THREAD_LINE_BATCHES
);
exit
(
2
);
}
char
*
info
=
taos_get_server_info
(
taos
);
char
*
info
=
taos_get_server_info
(
taos
);
printf
(
"server info: %s
\n
"
,
info
);
printf
(
"server info: %s
\n
"
,
info
);
...
@@ -175,10 +176,12 @@ int main(int argc, char* argv[]) {
...
@@ -175,10 +176,12 @@ int main(int argc, char* argv[]) {
linesStb
[
i
]
=
lineStb
;
linesStb
[
i
]
=
lineStb
;
}
}
SThreadInsertArgs
args
=
{
0
};
SThreadInsertArgs
args
=
{
0
};
args
.
batches
=
calloc
(
maxBatchesPerThread
,
sizeof
(
maxBatchesPerThread
));
args
.
taos
=
taos
;
args
.
taos
=
taos
;
args
.
batches
[
0
].
lines
=
linesStb
;
args
.
batches
[
0
].
lines
=
linesStb
;
args
.
batches
[
0
].
numLines
=
numSuperTables
;
args
.
batches
[
0
].
numLines
=
numSuperTables
;
insertLines
(
&
args
);
insertLines
(
&
args
);
free
(
args
.
batches
);
for
(
int
i
=
0
;
i
<
numSuperTables
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSuperTables
;
++
i
)
{
free
(
linesStb
[
i
]);
free
(
linesStb
[
i
]);
}
}
...
@@ -189,6 +192,7 @@ int main(int argc, char* argv[]) {
...
@@ -189,6 +192,7 @@ int main(int argc, char* argv[]) {
pthread_t
*
tids
=
calloc
(
numThreads
,
sizeof
(
pthread_t
));
pthread_t
*
tids
=
calloc
(
numThreads
,
sizeof
(
pthread_t
));
SThreadInsertArgs
*
argsThread
=
calloc
(
numThreads
,
sizeof
(
SThreadInsertArgs
));
SThreadInsertArgs
*
argsThread
=
calloc
(
numThreads
,
sizeof
(
SThreadInsertArgs
));
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
argsThread
[
i
].
batches
=
calloc
(
maxBatchesPerThread
,
sizeof
(
SThreadLinesBatch
));
argsThread
[
i
].
taos
=
taos
;
argsThread
[
i
].
taos
=
taos
;
argsThread
[
i
].
numBatches
=
0
;
argsThread
[
i
].
numBatches
=
0
;
}
}
...
@@ -248,6 +252,9 @@ int main(int argc, char* argv[]) {
...
@@ -248,6 +252,9 @@ int main(int argc, char* argv[]) {
}
}
free
(
allBatches
);
free
(
allBatches
);
for
(
int
i
=
0
;
i
<
numThreads
;
i
++
)
{
free
(
argsThread
[
i
].
batches
);
}
free
(
argsThread
);
free
(
argsThread
);
free
(
tids
);
free
(
tids
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录