Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
11b1467d
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看板
提交
11b1467d
编写于
2月 05, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2771] feature: python taosdemo. adjust debug output.
上级
59de8578
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
28 deletion
+31
-28
tests/examples/python/taosdemo/README.md
tests/examples/python/taosdemo/README.md
+1
-1
tests/examples/python/taosdemo/taosdemo.py
tests/examples/python/taosdemo/taosdemo.py
+30
-27
未找到文件。
tests/examples/python/taosdemo/README.md
浏览文件 @
11b1467d
...
...
@@ -21,7 +21,7 @@ Author: Shuduo Sang <sangshuduo@gmail.com>
-m, --tbname <table prefix> table_prefix, Table prefix name. Default is 't'.
-M, --stable flag, Use super table. Default is no
-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is 'st'
-Q, --query <DEFAULT | command> query, Execute query command. set 'DEFAULT' means select * from each table
-Q, --query <DEFAULT |
NO |
command> query, Execute query command. set 'DEFAULT' means select * from each table
-T, --threads <number> num_of_threads, The number of threads. Default is 1.
-C, --processes <number> num_of_processes, The number of threads. Default is 1.
-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000.
...
...
tests/examples/python/taosdemo/taosdemo.py
浏览文件 @
11b1467d
...
...
@@ -101,7 +101,7 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str):
v_print
(
"resp status: %d"
,
resp
.
status_code
)
if
verbose
:
if
debug
:
v_print
(
"resp text: %s"
,
json
.
dumps
(
...
...
@@ -138,7 +138,7 @@ def query_data_process(q_lock, i: int, cmd: str):
v_print
(
"Process:%d threads: %d cmd: %s"
,
i
,
threads
,
cmd
)
q_lock
.
aquire
()
cursor
_p
.
execute
(
cmd
)
cursor
.
execute
(
cmd
)
q_lock
.
release
()
return
i
...
...
@@ -171,7 +171,7 @@ def insert_data(processes: int):
remainder
=
numOfTb
%
processes
v_print
(
"num of tables: %d, quotient: %d, remainder: %d"
,
"
insert_data
num of tables: %d, quotient: %d, remainder: %d"
,
numOfTb
,
quotient
,
remainder
)
...
...
@@ -367,9 +367,9 @@ def create_tb():
(
tbName
,
j
))
def
insert_data_process
(
lock
,
i
:
int
,
begin
:
int
,
end
:
int
):
print
(
"CBD insert_data_process:%d table from %d to %d, tasks %d"
,
i
,
begin
,
end
,
tasks
)
time
.
sleep
(
1
)
def
insert_data_process
(
i_
lock
,
i
:
int
,
begin
:
int
,
end
:
int
):
print
(
"CBD
LN371
insert_data_process:%d table from %d to %d, tasks %d"
,
i
,
begin
,
end
,
tasks
)
time
.
sleep
(
0.0
1
)
tasks
=
end
-
begin
i_lock
.
aquire
()
...
...
@@ -397,6 +397,23 @@ def insert_data_process(lock, i: int, begin: int, end: int):
wait
(
workers
,
return_when
=
ALL_COMPLETED
)
i_lock
.
release
()
def
query_db
(
i
):
if
native
:
cursor
.
execute
(
"USE %s%d"
%
(
dbName
,
i
))
else
:
restful_execute
(
host
,
port
,
user
,
password
,
"USE %s%d"
%
(
dbName
,
i
))
for
j
in
range
(
0
,
numOfTb
):
if
native
:
cursor
.
execute
(
"SELECT COUNT(*) FROM %s%d"
%
(
tbName
,
j
))
else
:
restful_execute
(
host
,
port
,
user
,
password
,
"SELECT COUNT(*) FROM %s%d"
%
(
tbName
,
j
))
def
printConfig
():
...
...
@@ -439,6 +456,7 @@ if __name__ == "__main__":
native
=
False
verbose
=
False
debug
=
False
measure
=
True
dropDbOnly
=
False
colsPerRecord
=
3
...
...
@@ -516,7 +534,7 @@ if __name__ == "__main__":
'
\t
-M, --stable flag, Use super table. Default is no'
)
print
(
'
\t
-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is
\'
st
\'
'
)
print
(
'
\t
-Q, --query <DEFAULT | command> query, Execute query command. set
\'
DEFAULT
\'
means select * from each table'
)
print
(
'
\t
-Q, --query <DEFAULT |
NO |
command> query, Execute query command. set
\'
DEFAULT
\'
means select * from each table'
)
print
(
'
\t
-T, --threads <number> num_of_threads, The number of threads. Default is 1.'
)
print
(
...
...
@@ -728,28 +746,12 @@ if __name__ == "__main__":
create_tb
()
insert_data
(
processes
)
if
verbose
:
if
debug
:
for
i
in
range
(
0
,
numOfDb
):
if
native
:
cursor
.
execute
(
"USE %s%d"
%
(
dbName
,
i
))
else
:
restful_execute
(
host
,
port
,
user
,
password
,
"USE %s%d"
%
(
dbName
,
i
))
for
j
in
range
(
0
,
numOfTb
):
if
native
:
cursor
.
execute
(
"SELECT COUNT(*) FROM %s%d"
%
(
tbName
,
j
))
else
:
restful_execute
(
host
,
port
,
user
,
password
,
"SELECT COUNT(*) FROM %s%d"
%
(
tbName
,
j
))
query_db
(
i
)
if
queryCmd
!=
"
DEFAULT
"
:
if
queryCmd
!=
"
NO
"
:
print
(
"queryCmd: %s"
%
queryCmd
)
# cursor.close() ##
# conn.close() ## CBD
query_data
(
queryCmd
)
sys
.
exit
(
0
)
...
...
@@ -757,9 +759,10 @@ if __name__ == "__main__":
cursor
.
close
()
conn
.
close
()
print
(
"done"
)
if
measure
:
end_time
=
time
.
time
()
print
(
"Total time consumed {} seconds."
.
format
(
(
end_time
-
start_time
)))
print
(
"done"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录