Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
TDengine
提交
993b4a01
TDengine
项目概览
lzh_me
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
993b4a01
编写于
8月 24, 2021
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6295][ci skip]<test>: Update performace test script for perfMonitor
上级
7dcf6828
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
92 addition
and
41 deletion
+92
-41
tests/pytest/query/queryPerformance.py
tests/pytest/query/queryPerformance.py
+86
-26
tests/pytest/tools/taosdemoPerformance.py
tests/pytest/tools/taosdemoPerformance.py
+6
-15
未找到文件。
tests/pytest/query/queryPerformance.py
浏览文件 @
993b4a01
...
...
@@ -17,6 +17,7 @@ import os
import
taos
import
time
import
argparse
import
json
class
taosdemoQueryPerformace
:
...
...
@@ -48,7 +49,7 @@ class taosdemoQueryPerformace:
cursor2
=
self
.
conn2
.
cursor
()
cursor2
.
execute
(
"create database if not exists %s"
%
self
.
dbName
)
cursor2
.
execute
(
"use %s"
%
self
.
dbName
)
cursor2
.
execute
(
"create table if not exists %s(ts timestamp, query_time float, commit_id binary(50), branch binary(50), type binary(20)) tags(query_id int, query_sql binary(300))"
%
self
.
stbName
)
cursor2
.
execute
(
"create table if not exists %s(ts timestamp, query_time
_avg float, query_time_max float, query_time_min
float, commit_id binary(50), branch binary(50), type binary(20)) tags(query_id int, query_sql binary(300))"
%
self
.
stbName
)
sql
=
"select count(*) from test.meters"
tableid
=
1
...
...
@@ -74,7 +75,7 @@ class taosdemoQueryPerformace:
tableid
=
6
cursor2
.
execute
(
"create table if not exists %s%d using %s tags(%d, '%s')"
%
(
self
.
tbPerfix
,
tableid
,
self
.
stbName
,
tableid
,
sql
))
sql
=
"select * from meters"
sql
=
"select * from meters
limit 10000
"
tableid
=
7
cursor2
.
execute
(
"create table if not exists %s%d using %s tags(%d, '%s')"
%
(
self
.
tbPerfix
,
tableid
,
self
.
stbName
,
tableid
,
sql
))
...
...
@@ -88,36 +89,95 @@ class taosdemoQueryPerformace:
cursor2
.
close
()
def
generateQueryJson
(
self
):
sqls
=
[]
cursor2
=
self
.
conn2
.
cursor
()
cursor2
.
execute
(
"select query_id, query_sql from %s.%s"
%
(
self
.
dbName
,
self
.
stbName
))
i
=
0
for
data
in
cursor2
:
sql
=
{
"sql"
:
data
[
1
],
"result_mode"
:
"onlyformat"
,
"result_file"
:
"./query_sql_res%d.txt"
%
i
}
sqls
.
append
(
sql
)
i
+=
1
query_data
=
{
"filetype"
:
"query"
,
"cfgdir"
:
"/etc/perf"
,
"host"
:
"127.0.0.1"
,
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"databases"
:
"test"
,
"specified_table_query"
:
{
"query_times"
:
100
,
"concurrent"
:
1
,
"sqls"
:
sqls
}
}
query_json_file
=
f
"/tmp/query.json"
with
open
(
query_json_file
,
'w'
)
as
f
:
json
.
dump
(
query_data
,
f
)
return
query_json_file
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosdemo"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
getCMDOutput
(
self
,
cmd
):
cmd
=
os
.
popen
(
cmd
)
output
=
cmd
.
read
()
cmd
.
close
()
return
output
def
query
(
self
):
cursor
=
self
.
conn
.
cursor
()
print
(
"==================== query performance ===================="
)
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
print
(
"taosdemo not found!"
)
sys
.
exit
(
1
)
binPath
=
buildPath
+
"/build/bin/"
os
.
system
(
"%sperfMonitor -f %s > query_res.txt"
%
(
binPath
,
self
.
generateQueryJson
()))
cursor
=
self
.
conn2
.
cursor
()
print
(
"==================== query performance ===================="
)
cursor
.
execute
(
"use %s"
%
self
.
dbName
)
cursor
.
execute
(
"select tbname, query_
id, query_
sql from %s"
%
self
.
stbName
)
cursor
.
execute
(
"select tbname, query_sql from %s"
%
self
.
stbName
)
i
=
0
for
data
in
cursor
:
table_name
=
data
[
0
]
query_id
=
data
[
1
]
sql
=
data
[
2
]
totalTime
=
0
cursor2
=
self
.
conn
.
cursor
()
cursor2
.
execute
(
"use test"
)
for
i
in
range
(
100
):
if
(
self
.
clearCache
==
True
):
# root permission is required
os
.
system
(
"echo 3 > /proc/sys/vm/drop_caches"
)
startTime
=
time
.
time
()
cursor2
.
execute
(
sql
)
totalTime
+=
time
.
time
()
-
startTime
cursor2
.
close
()
print
(
"query time for: %s %f seconds"
%
(
sql
,
totalTime
/
100
))
sql
=
data
[
1
]
self
.
avgDelay
=
self
.
getCMDOutput
(
"grep 'avgDelay' query_res.txt | awk 'NR==%d{print $2}'"
%
(
i
+
1
))
self
.
maxDelay
=
self
.
getCMDOutput
(
"grep 'avgDelay' query_res.txt | awk 'NR==%d{print $5}'"
%
(
i
+
1
))
self
.
minDelay
=
self
.
getCMDOutput
(
"grep 'avgDelay' query_res.txt | awk 'NR==%d{print $8}'"
%
(
i
+
1
))
i
+=
1
cursor3
=
self
.
conn2
.
cursor
()
cursor3
.
execute
(
"insert into %s.%s values(now, %f, '%s', '%s', '%s')"
%
(
self
.
dbName
,
table_name
,
totalTime
/
100
,
self
.
commitID
,
self
.
branch
,
self
.
type
))
print
(
"query time for: %s %f seconds"
%
(
sql
,
float
(
self
.
avgDelay
)))
c
=
self
.
conn2
.
cursor
()
c
.
execute
(
"insert into %s.%s values(now, %f, %f, %f, '%s', '%s', '%s')"
%
(
self
.
dbName
,
table_name
,
float
(
self
.
avgDelay
),
float
(
self
.
maxDelay
),
float
(
self
.
minDelay
),
self
.
commitID
,
self
.
branch
,
self
.
type
))
c
ursor3
.
close
()
c
.
close
()
cursor
.
close
()
if
__name__
==
'__main__'
:
...
...
tests/pytest/tools/taosdemoPerformance.py
浏览文件 @
993b4a01
...
...
@@ -49,24 +49,18 @@ class taosdemoPerformace:
def
generateJson
(
self
):
db
=
{
"name"
:
"%s"
%
self
.
insertDB
,
"drop"
:
"yes"
,
"replica"
:
1
"drop"
:
"yes"
}
stb
=
{
"name"
:
"meters"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
self
.
numOfTables
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
"data_source"
:
"rand"
,
"batch_create_tbl_num"
:
10
,
"insert_mode"
:
"
taosc
"
,
"insert_mode"
:
"
rand
"
,
"insert_rows"
:
self
.
numOfRows
,
"interlace_rows"
:
0
,
"max_sql_len"
:
1024000
,
"disorder_ratio"
:
0
,
"disorder_range"
:
1000
,
"batch_rows"
:
1000000
,
"max_sql_len"
:
1048576
,
"timestamp_step"
:
1
,
"start_timestamp"
:
"2020-10-01 00:00:00.000"
,
"sample_format"
:
"csv"
,
...
...
@@ -100,11 +94,8 @@ class taosdemoPerformace:
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
10
,
"thread_count_create_tbl"
:
10
,
"thread_count_create_tbl"
:
4
,
"result_file"
:
"./insert_res.txt"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
30000
,
"databases"
:
[
db
]
}
...
...
@@ -145,7 +136,7 @@ class taosdemoPerformace:
binPath
=
buildPath
+
"/build/bin/"
os
.
system
(
"%s
taosdemo
-f %s > /dev/null 2>&1"
%
"%s
perfMonitor
-f %s > /dev/null 2>&1"
%
(
binPath
,
self
.
generateJson
()))
self
.
createTableTime
=
self
.
getCMDOutput
(
"grep 'Spent' insert_res.txt | awk 'NR==1{print $2}'"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录