Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
af4fba90
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
af4fba90
编写于
8月 29, 2021
作者:
J
jiajingbin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify some functions
上级
0b2f67e5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
29 deletion
+30
-29
tests/pytest/tools/schemalessInsertPerformance.py
tests/pytest/tools/schemalessInsertPerformance.py
+30
-29
未找到文件。
tests/pytest/tools/schemalessInsertPerformance.py
浏览文件 @
af4fba90
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
import
random
import
random
import
time
import
time
from
copy
import
deepcopy
from
copy
import
deepcopy
import
numpy
as
np
from
util.log
import
*
from
util.log
import
*
from
util.cases
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sql
import
*
...
@@ -125,20 +124,21 @@ class TDTestCase:
...
@@ -125,20 +124,21 @@ class TDTestCase:
end
=
time
.
time_ns
();
end
=
time
.
time_ns
();
print
(
threading
.
current_thread
().
name
,
'end time:'
,
(
end
-
begin
)
/
10
**
9
)
print
(
threading
.
current_thread
().
name
,
'end time:'
,
(
end
-
begin
)
/
10
**
9
)
def
splitGenerator
(
self
,
table_list
,
sub_list_len
):
def
splitGenerator
(
self
,
table_list
,
thread_count
):
'''
'''
split a list to n piece of sub_list
split a list to n piece of sub_list
[a, b, c, d] ---> [[a, b], [c, d]]
[a, b, c, d] ---> [[a, b], [c, d]]
yield type ---> generator
yield type ---> generator
'''
'''
sub_list_len
=
int
(
len
(
table_list
)
/
thread_count
)
for
i
in
range
(
0
,
len
(
table_list
),
sub_list_len
):
for
i
in
range
(
0
,
len
(
table_list
),
sub_list_len
):
yield
table_list
[
i
:
i
+
sub_list_len
]
yield
table_list
[
i
:
i
+
sub_list_len
]
def
genTbListGenerator
(
self
,
table_list
,
sub_list_len
):
def
genTbListGenerator
(
self
,
table_list
,
thread_count
):
'''
'''
split table_list, after split
, every sub_list len is sub_list_len
split table_list, after split
'''
'''
table_list_generator
=
self
.
splitGenerator
(
table_list
,
sub_list_len
)
table_list_generator
=
self
.
splitGenerator
(
table_list
,
thread_count
)
return
table_list_generator
return
table_list_generator
def
genTableList
(
self
,
count
=
4
,
table_count
=
10000
):
def
genTableList
(
self
,
count
=
4
,
table_count
=
10000
):
...
@@ -194,14 +194,14 @@ class TDTestCase:
...
@@ -194,14 +194,14 @@ class TDTestCase:
for
t
in
threads
:
for
t
in
threads
:
t
.
join
()
t
.
join
()
def
createTables
(
self
,
count
,
table_count
=
10000
,
sub_list_len
=
1000
,
thread_count
=
10
):
def
createTables
(
self
,
count
,
table_count
=
10000
,
thread_count
=
10
):
'''
'''
create stb and tb
create stb and tb
'''
'''
table_list
=
self
.
genTableList
(
count
=
count
,
table_count
=
table_count
)
table_list
=
self
.
genTableList
(
count
=
count
,
table_count
=
table_count
)
create_tables_start_time
=
time
.
time
()
create_tables_start_time
=
time
.
time
()
self
.
createStb
(
count
=
count
)
self
.
createStb
(
count
=
count
)
table_list_generator
=
self
.
genTbListGenerator
(
table_list
,
sub_list_len
)
table_list_generator
=
self
.
genTbListGenerator
(
table_list
,
thread_count
)
create_tables_generator
,
insert_rows_generator
=
itertools
.
tee
(
table_list_generator
,
2
)
create_tables_generator
,
insert_rows_generator
=
itertools
.
tee
(
table_list_generator
,
2
)
self
.
multiThreadRun
(
self
.
threadCreateTables
(
table_list_generator
=
create_tables_generator
,
thread_count
=
thread_count
))
self
.
multiThreadRun
(
self
.
threadCreateTables
(
table_list_generator
=
create_tables_generator
,
thread_count
=
thread_count
))
create_tables_end_time
=
time
.
time
()
create_tables_end_time
=
time
.
time
()
...
@@ -220,44 +220,45 @@ class TDTestCase:
...
@@ -220,44 +220,45 @@ class TDTestCase:
return_str
=
f
'insert rows
\'
time of
{
count
}
columns --->
{
insert_rows_time
}
s'
return_str
=
f
'insert rows
\'
time of
{
count
}
columns --->
{
insert_rows_time
}
s'
return
insert_rows_time
,
return_str
return
insert_rows_time
,
return_str
def
schemalessPerfTest
(
self
,
count
,
table_count
=
10000
,
sub_list_len
=
1000
,
thread_count
=
1
0
):
def
schemalessPerfTest
(
self
,
count
,
table_count
=
10000
,
thread_count
=
10
,
rows_count
=
100
0
):
'''
'''
get performance
get performance
'''
'''
insert_rows_generator
=
self
.
createTables
(
count
=
count
,
table_count
=
table_count
,
sub_list_len
=
sub_list_len
,
thread_count
=
thread_count
)[
0
]
insert_rows_generator
=
self
.
createTables
(
count
=
count
,
table_count
=
table_count
,
thread_count
=
thread_count
)[
0
]
return
self
.
insertRows
(
count
=
count
,
rows_generator
=
insert_rows_generator
,
rows_count
=
1000
,
thread_count
=
10
)
return
self
.
insertRows
(
count
=
count
,
rows_generator
=
insert_rows_generator
,
rows_count
=
rows_count
,
thread_count
=
thread_count
)
def
getPerfResults
(
self
,
test_times
=
3
,
table_count
=
10000
,
sub_list_len
=
1000
,
thread_count
=
10
):
def
getPerfResults
(
self
,
test_times
=
3
,
table_count
=
10000
,
thread_count
=
10
):
col4_time
=
0
col4_time
=
0
col1000_time
=
0
col1000_time
=
0
col4000_time
=
0
col4000_time
=
0
# for i in range(test_times):
# time_used = self.schemalessPerfTest(count=4, table_count=table_count, sub_list_len=sub_list_len, thread_count=thread_count)[0]
# col4_time += time_used
# col4_time /= test_times
# print(col4_time)
tdCom
.
cleanTb
()
for
i
in
range
(
test_times
):
for
i
in
range
(
test_times
):
time_used
=
self
.
schemalessPerfTest
(
count
=
1000
,
table_count
=
table_count
,
sub_list_len
=
sub_list_len
,
thread_count
=
thread_count
)[
0
]
tdCom
.
cleanTb
()
col1000_time
+=
time_used
time_used
=
self
.
schemalessPerfTest
(
count
=
4
,
table_count
=
table_count
,
thread_count
=
thread_count
)[
0
]
col1000_time
/=
test_times
col4_time
+=
time_used
print
(
col1000_time
)
col4_time
/=
test_times
print
(
col4_time
)
# for i in range(test_times):
# tdCom.cleanTb()
# time_used = self.schemalessPerfTest(count=1000, table_count=table_count, thread_count=thread_count)[0]
# col1000_time += time_used
# col1000_time /= test_times
# print(col1000_time)
tdCom
.
cleanTb
()
# for i in range(test_times):
for
i
in
range
(
test_times
):
# tdCom.cleanTb()
time_used
=
self
.
schemalessPerfTest
(
count
=
4000
,
table_count
=
table_count
,
sub_list_len
=
sub_list_len
,
thread_count
=
thread_count
)[
0
]
# time_used = self.schemalessPerfTest(count=4000, table_count=table_count
, thread_count=thread_count)[0]
col4000_time
+=
time_used
#
col4000_time += time_used
col4000_time
/=
test_times
#
col4000_time /= test_times
print
(
col4000_time
)
#
print(col4000_time)
return
col4_time
,
col1000_time
,
col4000_time
return
col4_time
,
col1000_time
,
col4000_time
def
run
(
self
):
def
run
(
self
):
print
(
"running {}"
.
format
(
__file__
))
print
(
"running {}"
.
format
(
__file__
))
tdSql
.
prepare
()
tdSql
.
prepare
()
result
=
self
.
getPerfResults
(
test_times
=
1
,
table_count
=
1000
,
sub_list_len
=
100
,
thread_count
=
10
)
result
=
self
.
getPerfResults
(
test_times
=
1
,
table_count
=
1000
,
thread_count
=
10
)
print
(
result
)
print
(
result
)
def
stop
(
self
):
def
stop
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录