Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a0d82449
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
a0d82449
编写于
8月 29, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
schemaless: add multi-thread performance test
上级
44f1c1e7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
24 addition
and
11 deletion
+24
-11
tests/examples/c/schemaless.c
tests/examples/c/schemaless.c
+24
-11
未找到文件。
tests/examples/c/schemaless.c
浏览文件 @
a0d82449
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
int
numThreads
=
8
;
int
numThreads
=
8
;
int
numSuperTables
=
8
;
int
numSuperTables
=
8
;
int
numChildTables
PerThread
=
4
;
int
numChildTables
=
4
;
// per thread, per super table
int
numRowsPerChildTable
=
2048
;
int
numRowsPerChildTable
=
2048
;
void
shuffle
(
char
**
lines
,
size_t
n
)
{
void
shuffle
(
char
**
lines
,
size_t
n
)
{
...
@@ -42,6 +42,7 @@ typedef struct {
...
@@ -42,6 +42,7 @@ typedef struct {
TAOS
*
taos
;
TAOS
*
taos
;
char
**
lines
;
char
**
lines
;
int
numLines
;
int
numLines
;
int64_t
costTime
;
}
SThreadInsertArgs
;
}
SThreadInsertArgs
;
static
void
*
insertLines
(
void
*
args
)
{
static
void
*
insertLines
(
void
*
args
)
{
...
@@ -52,6 +53,7 @@ static void* insertLines(void* args) {
...
@@ -52,6 +53,7 @@ static void* insertLines(void* args) {
int64_t
begin
=
getTimeInUs
();
int64_t
begin
=
getTimeInUs
();
int32_t
code
=
taos_insert_lines
(
insertArgs
->
taos
,
insertArgs
->
lines
,
insertArgs
->
numLines
);
int32_t
code
=
taos_insert_lines
(
insertArgs
->
taos
,
insertArgs
->
lines
,
insertArgs
->
numLines
);
int64_t
end
=
getTimeInUs
();
int64_t
end
=
getTimeInUs
();
insertArgs
->
costTime
=
end
-
begin
;
printf
(
"code: %d, %s. time used:%"
PRId64
", thread: 0x%s
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
,
tidBuf
);
printf
(
"code: %d, %s. time used:%"
PRId64
", thread: 0x%s
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
,
tidBuf
);
return
NULL
;
return
NULL
;
}
}
...
@@ -91,8 +93,8 @@ int main(int argc, char* argv[]) {
...
@@ -91,8 +93,8 @@ int main(int argc, char* argv[]) {
for
(
int
i
=
0
;
i
<
numSuperTables
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numSuperTables
;
i
++
)
{
char
*
lineStb
=
calloc
(
512
,
1
);
char
*
lineStb
=
calloc
(
512
,
1
);
snprintf
(
lineStb
,
512
,
lineFormat
,
i
,
snprintf
(
lineStb
,
512
,
lineFormat
,
i
,
numThreads
*
numSuperTables
*
numChildTables
PerThread
,
numThreads
*
numSuperTables
*
numChildTables
,
ts
+
numThreads
*
numSuperTables
*
numChildTables
PerThread
*
numRowsPerChildTable
);
ts
+
numThreads
*
numSuperTables
*
numChildTables
*
numRowsPerChildTable
);
linesStb
[
i
]
=
lineStb
;
linesStb
[
i
]
=
lineStb
;
}
}
SThreadInsertArgs
args
=
{
0
};
SThreadInsertArgs
args
=
{
0
};
...
@@ -109,7 +111,7 @@ int main(int argc, char* argv[]) {
...
@@ -109,7 +111,7 @@ int main(int argc, char* argv[]) {
printf
(
"generate lines...
\n
"
);
printf
(
"generate lines...
\n
"
);
char
***
linesThread
=
calloc
(
numThreads
,
sizeof
(
char
**
));
char
***
linesThread
=
calloc
(
numThreads
,
sizeof
(
char
**
));
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
char
**
lines
=
calloc
(
numSuperTables
*
numChildTables
PerThread
*
numRowsPerChildTable
,
sizeof
(
char
*
));
char
**
lines
=
calloc
(
numSuperTables
*
numChildTables
*
numRowsPerChildTable
,
sizeof
(
char
*
));
linesThread
[
i
]
=
lines
;
linesThread
[
i
]
=
lines
;
}
}
...
@@ -117,10 +119,10 @@ int main(int argc, char* argv[]) {
...
@@ -117,10 +119,10 @@ int main(int argc, char* argv[]) {
int
l
=
0
;
int
l
=
0
;
char
**
lines
=
linesThread
[
t
];
char
**
lines
=
linesThread
[
t
];
for
(
int
i
=
0
;
i
<
numSuperTables
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numSuperTables
;
++
i
)
{
for
(
int
j
=
0
;
j
<
numChildTables
PerThread
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numChildTables
;
++
j
)
{
for
(
int
k
=
0
;
k
<
numRowsPerChildTable
;
++
k
)
{
for
(
int
k
=
0
;
k
<
numRowsPerChildTable
;
++
k
)
{
int
stIdx
=
i
;
int
stIdx
=
i
;
int
ctIdx
=
t
*
numSuperTables
*
numChildTables
PerThread
+
j
;
int
ctIdx
=
t
*
numSuperTables
*
numChildTables
+
j
;
char
*
line
=
calloc
(
512
,
1
);
char
*
line
=
calloc
(
512
,
1
);
snprintf
(
line
,
512
,
lineFormat
,
stIdx
,
ctIdx
,
ts
+
10
*
l
);
snprintf
(
line
,
512
,
lineFormat
,
stIdx
,
ctIdx
,
ts
+
10
*
l
);
lines
[
l
]
=
line
;
lines
[
l
]
=
line
;
...
@@ -132,24 +134,35 @@ int main(int argc, char* argv[]) {
...
@@ -132,24 +134,35 @@ int main(int argc, char* argv[]) {
printf
(
"shuffle lines...
\n
"
);
printf
(
"shuffle lines...
\n
"
);
for
(
int
t
=
0
;
t
<
numThreads
;
++
t
)
{
for
(
int
t
=
0
;
t
<
numThreads
;
++
t
)
{
shuffle
(
linesThread
[
t
],
numSuperTables
*
numChildTables
PerThread
*
numRowsPerChildTable
);
shuffle
(
linesThread
[
t
],
numSuperTables
*
numChildTables
*
numRowsPerChildTable
);
}
}
printf
(
"begin multi-thread insertion..."
);
printf
(
"begin multi-thread insertion...
\n
"
);
int64_t
begin
=
taosGetTimestampUs
();
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
].
lines
=
linesThread
[
i
];
argsThread
[
i
].
lines
=
linesThread
[
i
];
argsThread
[
i
].
taos
=
taos
;
argsThread
[
i
].
taos
=
taos
;
argsThread
[
i
].
numLines
=
numSuperTables
*
numChildTables
PerThread
*
numRowsPerChildTable
;
argsThread
[
i
].
numLines
=
numSuperTables
*
numChildTables
*
numRowsPerChildTable
;
pthread_create
(
tids
+
i
,
NULL
,
insertLines
,
argsThread
+
i
);
pthread_create
(
tids
+
i
,
NULL
,
insertLines
,
argsThread
+
i
);
}
}
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
pthread_join
(
tids
[
i
],
NULL
);
pthread_join
(
tids
[
i
],
NULL
);
}
}
int64_t
end
=
taosGetTimestampUs
();
int
totalLines
=
numThreads
*
numSuperTables
*
numChildTables
*
numRowsPerChildTable
;
printf
(
"TOTAL LINES: %d
\n
"
,
totalLines
);
printf
(
"THREADS: %d
\n
"
,
numThreads
);
int64_t
sumTime
=
0
;
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
sumTime
+=
argsThread
[
i
].
costTime
;
}
printf
(
"TIME: %d(ms)
\n
"
,
(
int
)(
end
-
begin
)
/
1000
);
double
throughput
=
(
double
)(
totalLines
)
/
(
double
)(
end
-
begin
)
*
1000000
;
printf
(
"THROUGHPUT:%d/s
\n
"
,
(
int
)
throughput
);
free
(
argsThread
);
free
(
argsThread
);
free
(
tids
);
free
(
tids
);
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numThreads
;
++
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录