Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
283b5341
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
283b5341
编写于
1月 06, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add batch for create_table
上级
d10df1e3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
18 deletion
+20
-18
tests/test/c/create_table.c
tests/test/c/create_table.c
+20
-18
未找到文件。
tests/test/c/create_table.c
浏览文件 @
283b5341
...
@@ -15,25 +15,20 @@
...
@@ -15,25 +15,20 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taos.h"
#include "taos.h"
#include "taosdef.h"
#include "taoserror.h"
#include "taoserror.h"
#include "thash.h"
#include "tutil.h"
#include "ulog.h"
#include "ulog.h"
#define MAX_RANDOM_POINTS 20000
#define GREEN "\033[1;32m"
#define GREEN "\033[1;32m"
#define NC "\033[0m"
#define NC "\033[0m"
char
dbName
[
32
]
=
"db"
;
char
dbName
[
32
]
=
"db"
;
char
stbName
[
64
]
=
"st"
;
char
stbName
[
64
]
=
"st"
;
int32_t
numOfThreads
=
2
;
int32_t
numOfThreads
=
1
;
int32_t
numOfTables
=
10000
;
int32_t
numOfTables
=
10000
;
int32_t
createTable
=
1
;
int32_t
createTable
=
1
;
int32_t
insertData
=
0
;
int32_t
insertData
=
0
;
int32_t
batchNum
=
1
;
int32_t
batchNum
=
1
0
;
int32_t
numOfVgroups
=
2
;
int32_t
numOfVgroups
=
2
;
typedef
struct
{
typedef
struct
{
...
@@ -47,11 +42,11 @@ typedef struct {
...
@@ -47,11 +42,11 @@ typedef struct {
pthread_t
thread
;
pthread_t
thread
;
}
SThreadInfo
;
}
SThreadInfo
;
void
parseArgument
(
int
argc
,
char
*
argv
[]);
void
parseArgument
(
int
32_t
argc
,
char
*
argv
[]);
void
*
threadFunc
(
void
*
param
);
void
*
threadFunc
(
void
*
param
);
void
createDbAndStb
();
void
createDbAndStb
();
int
main
(
in
t
argc
,
char
*
argv
[])
{
int
32_t
main
(
int32_
t
argc
,
char
*
argv
[])
{
parseArgument
(
argc
,
argv
);
parseArgument
(
argc
,
argv
);
createDbAndStb
();
createDbAndStb
();
...
@@ -64,7 +59,7 @@ int main(int argc, char *argv[]) {
...
@@ -64,7 +59,7 @@ int main(int argc, char *argv[]) {
int32_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
int32_t
numOfTablesPerThread
=
numOfTables
/
numOfThreads
;
numOfTables
=
numOfTablesPerThread
*
numOfThreads
;
numOfTables
=
numOfTablesPerThread
*
numOfThreads
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
pInfo
[
i
].
tableBeginIndex
=
i
*
numOfTablesPerThread
;
pInfo
[
i
].
tableBeginIndex
=
i
*
numOfTablesPerThread
;
pInfo
[
i
].
tableEndIndex
=
(
i
+
1
)
*
numOfTablesPerThread
;
pInfo
[
i
].
tableEndIndex
=
(
i
+
1
)
*
numOfTablesPerThread
;
pInfo
[
i
].
threadIndex
=
i
;
pInfo
[
i
].
threadIndex
=
i
;
...
@@ -74,17 +69,17 @@ int main(int argc, char *argv[]) {
...
@@ -74,17 +69,17 @@ int main(int argc, char *argv[]) {
}
}
taosMsleep
(
300
);
taosMsleep
(
300
);
for
(
int
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
i
++
)
{
pthread_join
(
pInfo
[
i
].
thread
,
NULL
);
pthread_join
(
pInfo
[
i
].
thread
,
NULL
);
}
}
float
createTableSpeed
=
0
;
float
createTableSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
}
}
float
insertDataSpeed
=
0
;
float
insertDataSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
}
}
...
@@ -137,8 +132,8 @@ void createDbAndStb() {
...
@@ -137,8 +132,8 @@ void createDbAndStb() {
void
*
threadFunc
(
void
*
param
)
{
void
*
threadFunc
(
void
*
param
)
{
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
char
qstr
[
65000
]
;
char
*
qstr
=
malloc
(
2000
*
1000
)
;
int
code
;
int
32_t
code
=
0
;
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
con
==
NULL
)
{
if
(
con
==
NULL
)
{
...
@@ -153,7 +148,13 @@ void *threadFunc(void *param) {
...
@@ -153,7 +148,13 @@ void *threadFunc(void *param) {
if
(
createTable
)
{
if
(
createTable
)
{
int64_t
startMs
=
taosGetTimestampMs
();
int64_t
startMs
=
taosGetTimestampMs
();
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
for
(
int32_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
sprintf
(
qstr
,
"create table t%d using %s tags(%d)"
,
t
,
stbName
,
t
);
int32_t
batch
=
(
pInfo
->
tableEndIndex
-
t
);
batch
=
MIN
(
batch
,
batchNum
);
int32_t
len
=
sprintf
(
qstr
,
"create table"
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
len
+=
sprintf
(
qstr
+
len
,
" t%d using %s tags(%d)"
,
t
+
i
,
stbName
,
t
+
i
);
}
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -189,6 +190,7 @@ void *threadFunc(void *param) {
...
@@ -189,6 +190,7 @@ void *threadFunc(void *param) {
}
}
taos_close
(
con
);
taos_close
(
con
);
free
(
qstr
);
return
0
;
return
0
;
}
}
...
@@ -218,8 +220,8 @@ void printHelp() {
...
@@ -218,8 +220,8 @@ void printHelp() {
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
void
parseArgument
(
int
argc
,
char
*
argv
[])
{
void
parseArgument
(
int
32_t
argc
,
char
*
argv
[])
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
int
32_t
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
||
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
||
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
printHelp
();
exit
(
0
);
exit
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录