Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
232cf4e7
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
232cf4e7
编写于
7月 20, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add performance test
上级
dedbb754
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
0 deletion
+87
-0
tests/examples/c/CMakeLists.txt
tests/examples/c/CMakeLists.txt
+2
-0
tests/examples/c/schemaless.c
tests/examples/c/schemaless.c
+85
-0
未找到文件。
tests/examples/c/CMakeLists.txt
浏览文件 @
232cf4e7
...
...
@@ -5,6 +5,8 @@ IF (TD_LINUX)
AUX_SOURCE_DIRECTORY
(
. SRC
)
ADD_EXECUTABLE
(
demo apitest.c
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
sml schemaless.c
)
TARGET_LINK_LIBRARIES
(
sml taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
subscribe subscribe.c
)
TARGET_LINK_LIBRARIES
(
subscribe taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
epoll epoll.c
)
...
...
tests/examples/c/schemaless.c
0 → 100644
浏览文件 @
232cf4e7
#include "taos.h"
#include "taoserror.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
int
numSuperTables
=
8
;
int
numChildTables
=
1024
;
int
numRowsPerChildTable
=
128
;
void
shuffle
(
char
**
lines
,
size_t
n
)
{
if
(
n
>
1
)
{
size_t
i
;
for
(
i
=
0
;
i
<
n
-
1
;
i
++
)
{
size_t
j
=
i
+
rand
()
/
(
RAND_MAX
/
(
n
-
i
)
+
1
);
char
*
t
=
lines
[
j
];
lines
[
j
]
=
lines
[
i
];
lines
[
i
]
=
t
;
}
}
}
static
int64_t
getTimeInUs
()
{
struct
timeval
systemTime
;
gettimeofday
(
&
systemTime
,
NULL
);
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000L
+
(
int64_t
)
systemTime
.
tv_usec
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
TAOS_RES
*
result
;
const
char
*
host
=
"127.0.0.1"
;
const
char
*
user
=
"root"
;
const
char
*
passwd
=
"taosdata"
;
taos_options
(
TSDB_OPTION_TIMEZONE
,
"GMT-8"
);
TAOS
*
taos
=
taos_connect
(
host
,
user
,
passwd
,
""
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"
\033
[31mfailed to connect to db, reason:%s
\033
[0m
\n
"
,
taos_errstr
(
taos
));
exit
(
1
);
}
char
*
info
=
taos_get_server_info
(
taos
);
printf
(
"server info: %s
\n
"
,
info
);
info
=
taos_get_client_info
(
taos
);
printf
(
"client info: %s
\n
"
,
info
);
result
=
taos_query
(
taos
,
"drop database if exists db;"
);
taos_free_result
(
result
);
usleep
(
100000
);
result
=
taos_query
(
taos
,
"create database db precision 'ms';"
);
taos_free_result
(
result
);
usleep
(
100000
);
(
void
)
taos_select_db
(
taos
,
"db"
);
time_t
ct
=
time
(
0
);
int64_t
ts
=
ct
*
1000
;
char
*
lineFormat
=
"sta%d,t0=true,t1=127i8,t2=32767i16,t3=%di32,t4=9223372036854775807i64,t9=11.12345f32,t10=22.123456789f64,t11=
\"
binaryTagValue
\"
,t12=L
\"
ncharTagValue
\"
c0=true,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=255u8,c6=32770u16,c7=2147483699u32,c8=9223372036854775899u64,c9=11.12345f32,c10=22.123456789f64,c11=
\"
binaryValue
\"
,c12=L
\"
ncharValue
\"
%lldms"
;
char
**
lines
=
calloc
(
numSuperTables
*
numChildTables
*
numRowsPerChildTable
,
sizeof
(
char
*
));
int
l
=
0
;
for
(
int
i
=
0
;
i
<
numSuperTables
;
++
i
)
{
for
(
int
j
=
0
;
j
<
numChildTables
;
++
j
)
{
for
(
int
k
=
0
;
k
<
numRowsPerChildTable
;
++
k
)
{
char
*
line
=
calloc
(
512
,
1
);
snprintf
(
line
,
512
,
lineFormat
,
i
,
j
,
ts
+
10
*
l
);
lines
[
l
]
=
line
;
++
l
;
}
}
}
shuffle
(
lines
,
numSuperTables
*
numChildTables
*
numRowsPerChildTable
);
printf
(
"%s
\n
"
,
"begin taos_insert_lines"
);
int64_t
begin
=
getTimeInUs
();
int32_t
code
=
taos_insert_lines
(
taos
,
lines
,
numSuperTables
*
numChildTables
*
numRowsPerChildTable
);
int64_t
end
=
getTimeInUs
();
printf
(
"code: %d, %s, %ld
\n
"
,
code
,
tstrerror
(
code
),
end
-
begin
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录