[TD-2771] feature: python taosdemo. adjust debug output.
This commit is contained in:
parent
59de857840
commit
11b1467d5c
|
@ -21,7 +21,7 @@ Author: Shuduo Sang <sangshuduo@gmail.com>
|
||||||
-m, --tbname <table prefix> table_prefix, Table prefix name. Default is 't'.
|
-m, --tbname <table prefix> table_prefix, Table prefix name. Default is 't'.
|
||||||
-M, --stable flag, Use super table. Default is no
|
-M, --stable flag, Use super table. Default is no
|
||||||
-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is 'st'
|
-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.
|
-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.
|
-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.
|
-r, --batch <number> num_of_records_per_req, The number of records per request. Default is 1000.
|
||||||
|
|
|
@ -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)
|
v_print("resp status: %d", resp.status_code)
|
||||||
|
|
||||||
if verbose:
|
if debug:
|
||||||
v_print(
|
v_print(
|
||||||
"resp text: %s",
|
"resp text: %s",
|
||||||
json.dumps(
|
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)
|
v_print("Process:%d threads: %d cmd: %s", i, threads, cmd)
|
||||||
|
|
||||||
q_lock.aquire()
|
q_lock.aquire()
|
||||||
cursor_p.execute(cmd)
|
cursor.execute(cmd)
|
||||||
q_lock.release()
|
q_lock.release()
|
||||||
|
|
||||||
return i
|
return i
|
||||||
|
@ -171,7 +171,7 @@ def insert_data(processes: int):
|
||||||
|
|
||||||
remainder = numOfTb % processes
|
remainder = numOfTb % processes
|
||||||
v_print(
|
v_print(
|
||||||
"num of tables: %d, quotient: %d, remainder: %d",
|
"insert_data num of tables: %d, quotient: %d, remainder: %d",
|
||||||
numOfTb,
|
numOfTb,
|
||||||
quotient,
|
quotient,
|
||||||
remainder)
|
remainder)
|
||||||
|
@ -367,9 +367,9 @@ def create_tb():
|
||||||
(tbName, j))
|
(tbName, j))
|
||||||
|
|
||||||
|
|
||||||
def insert_data_process(lock, i: int, begin: int, end: int):
|
def insert_data_process(i_lock, i: int, begin: int, end: int):
|
||||||
print("CBD insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks)
|
print("CBD LN371 insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks)
|
||||||
time.sleep(1)
|
time.sleep(0.01)
|
||||||
tasks = end - begin
|
tasks = end - begin
|
||||||
i_lock.aquire()
|
i_lock.aquire()
|
||||||
|
|
||||||
|
@ -397,6 +397,23 @@ def insert_data_process(lock, i: int, begin: int, end: int):
|
||||||
wait(workers, return_when=ALL_COMPLETED)
|
wait(workers, return_when=ALL_COMPLETED)
|
||||||
i_lock.release()
|
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():
|
def printConfig():
|
||||||
|
|
||||||
|
@ -439,6 +456,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
native = False
|
native = False
|
||||||
verbose = False
|
verbose = False
|
||||||
|
debug = False
|
||||||
measure = True
|
measure = True
|
||||||
dropDbOnly = False
|
dropDbOnly = False
|
||||||
colsPerRecord = 3
|
colsPerRecord = 3
|
||||||
|
@ -516,7 +534,7 @@ if __name__ == "__main__":
|
||||||
'\t-M, --stable flag, Use super table. Default is no')
|
'\t-M, --stable flag, Use super table. Default is no')
|
||||||
print(
|
print(
|
||||||
'\t-s, --stbname <stable prefix> stable_prefix, STable prefix name. Default is \'st\'')
|
'\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(
|
print(
|
||||||
'\t-T, --threads <number> num_of_threads, The number of threads. Default is 1.')
|
'\t-T, --threads <number> num_of_threads, The number of threads. Default is 1.')
|
||||||
print(
|
print(
|
||||||
|
@ -728,28 +746,12 @@ if __name__ == "__main__":
|
||||||
create_tb()
|
create_tb()
|
||||||
insert_data(processes)
|
insert_data(processes)
|
||||||
|
|
||||||
if verbose:
|
if debug:
|
||||||
for i in range(0, numOfDb):
|
for i in range(0, numOfDb):
|
||||||
if native:
|
query_db(i)
|
||||||
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 queryCmd != "NO":
|
||||||
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))
|
|
||||||
|
|
||||||
if queryCmd != "DEFAULT":
|
|
||||||
print("queryCmd: %s" % queryCmd)
|
print("queryCmd: %s" % queryCmd)
|
||||||
# cursor.close() ##
|
|
||||||
# conn.close() ## CBD
|
|
||||||
query_data(queryCmd)
|
query_data(queryCmd)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -757,9 +759,10 @@ if __name__ == "__main__":
|
||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
print("done")
|
|
||||||
if measure:
|
if measure:
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
print(
|
print(
|
||||||
"Total time consumed {} seconds.".format(
|
"Total time consumed {} seconds.".format(
|
||||||
(end_time - start_time)))
|
(end_time - start_time)))
|
||||||
|
|
||||||
|
print("done")
|
||||||
|
|
Loading…
Reference in New Issue