[TD-5730]<test>: update performance test script
This commit is contained in:
parent
e45b047e5f
commit
d2aea28c24
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
branch=
|
branch=
|
||||||
if [ x$1 != x ];then
|
if [ x$1 != x ];then
|
||||||
branch=$1
|
branch=$1
|
||||||
|
@ -8,17 +9,19 @@ else
|
||||||
echo "Please enter branch name as a parameter"
|
echo "Please enter branch name as a parameter"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
jemalloc=
|
|
||||||
|
type=
|
||||||
if [ x$2 != x ];then
|
if [ x$2 != x ];then
|
||||||
jemalloc=jemalloc
|
type=jemalloc
|
||||||
echo "Building TDengine using jemalloc"
|
echo "Building TDengine using jemalloc"
|
||||||
else
|
else
|
||||||
|
type=glibc
|
||||||
echo "Building TDengine using glibc"
|
echo "Building TDengine using glibc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
today=`date +"%Y%m%d"`
|
today=`date +"%Y%m%d"`
|
||||||
WORK_DIR=/home/ubuntu/pxiao
|
WORK_DIR=/root/pxiao
|
||||||
PERFORMANCE_TEST_REPORT=$WORK_DIR/TDengine/tests/performance-test-report-$today.log
|
PERFORMANCE_TEST_REPORT=$WORK_DIR/TDengine/tests/performance-report-$branch-$type-$today.log
|
||||||
|
|
||||||
# Coloured Echoes #
|
# Coloured Echoes #
|
||||||
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
function red_echo { echo -e "\033[31m$@\033[0m"; } #
|
||||||
|
@ -64,52 +67,41 @@ function buildTDengine {
|
||||||
echo "REMOTE: $REMOTE_COMMIT"
|
echo "REMOTE: $REMOTE_COMMIT"
|
||||||
if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then
|
if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then
|
||||||
echo "repo up-to-date"
|
echo "repo up-to-date"
|
||||||
else
|
|
||||||
echo "repo need to pull"
|
|
||||||
git pull > /dev/null 2>&1
|
|
||||||
|
|
||||||
LOCAL_COMMIT=`git rev-parse --short @`
|
|
||||||
if [ $jemalloc = "jemalloc" ];then
|
|
||||||
echo "git submodule update --init --recursive"
|
|
||||||
git submodule update --init --recursive
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd debug
|
|
||||||
rm -rf *
|
|
||||||
|
|
||||||
if [ $jemalloc = "jemalloc" ];then
|
|
||||||
echo "cmake .. -DJEMALLOC_ENABLED=true > /dev/null"
|
|
||||||
cmake .. -DJEMALLOC_ENABLED=true > /dev/null
|
|
||||||
else
|
|
||||||
cmake .. > /dev/null
|
|
||||||
fi
|
|
||||||
make && make install > /dev/null
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
git pull > /dev/null 2>&1
|
||||||
|
if [ $type = "jemalloc" ];then
|
||||||
|
echo "git submodule update --init --recursive"
|
||||||
|
git submodule update --init --recursive
|
||||||
|
fi
|
||||||
|
LOCAL_COMMIT=`git rev-parse --short @`
|
||||||
|
cd debug
|
||||||
|
rm -rf *
|
||||||
|
if [ $type = "jemalloc" ];then
|
||||||
|
echo "cmake .. -DJEMALLOC_ENABLED=true > /dev/null"
|
||||||
|
cmake .. -DJEMALLOC_ENABLED=true > /dev/null
|
||||||
|
else
|
||||||
|
cmake .. > /dev/null
|
||||||
|
fi
|
||||||
|
make > /dev/null 2>&1
|
||||||
|
make install > /dev/null 2>&1
|
||||||
|
echo "Build TDengine on remote server"
|
||||||
|
ssh perftest "./buildTDengine.sh $branch > /dev/null"
|
||||||
}
|
}
|
||||||
|
|
||||||
function runQueryPerfTest {
|
function runQueryPerfTest {
|
||||||
[ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT
|
[ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT
|
||||||
nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/taosperf/ > /dev/null 2>&1 &
|
nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/perf/ > /dev/null 2>&1 &
|
||||||
echoInfo "Wait TDengine to start"
|
echoInfo "Wait TDengine to start"
|
||||||
sleep 60
|
sleep 60
|
||||||
echoInfo "Run Performance Test"
|
echoInfo "Run Performance Test"
|
||||||
cd $WORK_DIR/TDengine/tests/pytest
|
cd $WORK_DIR/TDengine/tests/pytest
|
||||||
|
|
||||||
python3 query/queryPerformance.py -c $LOCAL_COMMIT | tee -a $PERFORMANCE_TEST_REPORT
|
python3 query/queryPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT
|
||||||
|
|
||||||
mkdir -p /var/lib/perf/
|
python3 insert/insertFromCSVPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT
|
||||||
mkdir -p /var/log/perf/
|
|
||||||
rm -rf /var/lib/perf/*
|
|
||||||
rm -rf /var/log/perf/*
|
|
||||||
nohup $WORK_DIR/TDengine/debug/build/bin/taosd -c /etc/perf/ > /dev/null 2>&1 &
|
|
||||||
echoInfo "Wait TDengine to start"
|
|
||||||
sleep 10
|
|
||||||
echoInfo "Run Performance Test"
|
|
||||||
cd $WORK_DIR/TDengine/tests/pytest
|
|
||||||
|
|
||||||
python3 insert/insertFromCSVPerformance.py -c $LOCAL_COMMIT | tee -a $PERFORMANCE_TEST_REPORT
|
python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT
|
||||||
|
|
||||||
python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT | tee -a $PERFORMANCE_TEST_REPORT
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,8 +114,7 @@ function sendReport {
|
||||||
|
|
||||||
sed -i 's/\x1b\[[0-9;]*m//g' $PERFORMANCE_TEST_REPORT
|
sed -i 's/\x1b\[[0-9;]*m//g' $PERFORMANCE_TEST_REPORT
|
||||||
BODY_CONTENT=`cat $PERFORMANCE_TEST_REPORT`
|
BODY_CONTENT=`cat $PERFORMANCE_TEST_REPORT`
|
||||||
|
echo -e "From: <support@taosdata.com>\nto: ${receiver}\nsubject: Query Performace Report ${branch} ${jemalloc} commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \
|
||||||
echo -e "From: <support@taosdata.com>\nto: ${receiver}\nsubject: Query Performace Report ${branch} ${jemalloc} ${today}, commit ID: ${LOCAL_COMMIT}\n\n${today}:\n${BODY_CONTENT}" | \
|
|
||||||
(cat - && uuencode $PERFORMANCE_TEST_REPORT performance-test-report-$today.log) | \
|
(cat - && uuencode $PERFORMANCE_TEST_REPORT performance-test-report-$today.log) | \
|
||||||
/usr/sbin/ssmtp "${receiver}" && echo "Report Sent!"
|
/usr/sbin/ssmtp "${receiver}" && echo "Report Sent!"
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,12 @@ import argparse
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
class insertFromCSVPerformace:
|
class insertFromCSVPerformace:
|
||||||
def __init__(self, commitID, dbName, stbName, branchName):
|
def __init__(self, commitID, dbName, tbName, branchName, buildType):
|
||||||
self.commitID = commitID
|
self.commitID = commitID
|
||||||
self.dbName = dbName
|
self.dbName = dbName
|
||||||
self.stbName = stbName
|
self.tbName = tbName
|
||||||
self.branchName = branchName
|
self.branchName = branchName
|
||||||
|
self.type = buildType
|
||||||
self.ts = 1500074556514
|
self.ts = 1500074556514
|
||||||
self.host = "127.0.0.1"
|
self.host = "127.0.0.1"
|
||||||
self.user = "root"
|
self.user = "root"
|
||||||
|
@ -37,6 +38,12 @@ class insertFromCSVPerformace:
|
||||||
self.user,
|
self.user,
|
||||||
self.password,
|
self.password,
|
||||||
self.config)
|
self.config)
|
||||||
|
self.host2 = "192.168.1.179"
|
||||||
|
self.conn2 = taos.connect(
|
||||||
|
host = self.host2,
|
||||||
|
user = self.user,
|
||||||
|
password = self.password,
|
||||||
|
config = self.config)
|
||||||
|
|
||||||
def writeCSV(self):
|
def writeCSV(self):
|
||||||
with open('test3.csv','w', encoding='utf-8', newline='') as csvFile:
|
with open('test3.csv','w', encoding='utf-8', newline='') as csvFile:
|
||||||
|
@ -52,47 +59,43 @@ class insertFromCSVPerformace:
|
||||||
data = data.drop([0])
|
data = data.drop([0])
|
||||||
data.to_csv("ordered.csv", header = False, index = False)
|
data.to_csv("ordered.csv", header = False, index = False)
|
||||||
|
|
||||||
def createTables(self):
|
|
||||||
cursor = self.conn.cursor()
|
|
||||||
|
|
||||||
cursor.execute("create database if not exists %s" % self.dbName)
|
|
||||||
cursor.execute("use %s" % self.dbName)
|
|
||||||
cursor.execute("create table if not exists %s(ts timestamp, in_order_time float, out_of_order_time float, commit_id binary(50)) tags(branch binary(50))" % self.stbName)
|
|
||||||
cursor.execute("create table if not exists %s using %s tags('%s')" % (self.branchName, self.stbName, self.branchName))
|
|
||||||
|
|
||||||
cursor.execute("create table if not exists t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
|
|
||||||
cursor.execute("create table if not exists t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
|
|
||||||
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
cursor = self.conn.cursor()
|
cursor = self.conn.cursor()
|
||||||
|
cursor.execute("create database if not exists %s" % self.dbName)
|
||||||
cursor.execute("use %s" % self.dbName)
|
cursor.execute("use %s" % self.dbName)
|
||||||
print("==================== CSV insert performance ====================")
|
print("==================== CSV insert performance ====================")
|
||||||
|
|
||||||
totalTime = 0
|
totalTime = 0
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
cursor.execute("drop table if exists t1")
|
||||||
cursor.execute("create table if not exists t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
|
cursor.execute("create table if not exists t1(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
cursor.execute("insert into t1 file 'outoforder.csv'")
|
cursor.execute("insert into t1 file 'outoforder.csv'")
|
||||||
totalTime += time.time() - startTime
|
totalTime += time.time() - startTime
|
||||||
cursor.execute("drop table if exists t1")
|
|
||||||
out_of_order_time = (float) (totalTime / 10)
|
out_of_order_time = (float) (totalTime / 10)
|
||||||
print("Out of Order - Insert time: %f" % out_of_order_time)
|
print("Out of Order - Insert time: %f" % out_of_order_time)
|
||||||
|
|
||||||
totalTime = 0
|
totalTime = 0
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
cursor.execute("drop table if exists t2")
|
||||||
cursor.execute("create table if not exists t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
|
cursor.execute("create table if not exists t2(ts timestamp, c1 int, c2 float, c3 int, c4 int)")
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
cursor.execute("insert into t2 file 'ordered.csv'")
|
cursor.execute("insert into t2 file 'ordered.csv'")
|
||||||
totalTime += time.time() - startTime
|
totalTime += time.time() - startTime
|
||||||
cursor.execute("drop table if exists t2")
|
|
||||||
|
|
||||||
in_order_time = (float) (totalTime / 10)
|
in_order_time = (float) (totalTime / 10)
|
||||||
print("In order - Insert time: %f" % in_order_time)
|
print("In order - Insert time: %f" % in_order_time)
|
||||||
cursor.execute("insert into %s values(now, %f, %f, '%s')" % (self.branchName, in_order_time, out_of_order_time, self.commitID))
|
cursor.close()
|
||||||
|
|
||||||
|
|
||||||
|
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, in_order_time float, out_of_order_time float, commit_id binary(50), branch binary(50), type binary(20))" % self.tbName)
|
||||||
|
cursor2.execute("insert into %s values(now, %f, %f, '%s', '%s', '%s')" % (self.tbName, in_order_time, out_of_order_time, self.commitID, self.branchName, self.type))
|
||||||
|
|
||||||
|
cursor2.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -111,7 +114,7 @@ if __name__ == '__main__':
|
||||||
help='Database name to be created (default: perf)')
|
help='Database name to be created (default: perf)')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-t',
|
'-t',
|
||||||
'--stable-name',
|
'--table-name',
|
||||||
action='store',
|
action='store',
|
||||||
default='csv_insert',
|
default='csv_insert',
|
||||||
type=str,
|
type=str,
|
||||||
|
@ -123,9 +126,14 @@ if __name__ == '__main__':
|
||||||
default='develop',
|
default='develop',
|
||||||
type=str,
|
type=str,
|
||||||
help='branch name (default: develop)')
|
help='branch name (default: develop)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-T',
|
||||||
|
'--build-type',
|
||||||
|
action='store',
|
||||||
|
default='glibc',
|
||||||
|
type=str,
|
||||||
|
help='build type (default: glibc)')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
perftest = insertFromCSVPerformace(args.commit_id, args.database_name, args.stable_name, args.branch_name)
|
perftest = insertFromCSVPerformace(args.commit_id, args.database_name, args.table_name, args.branch_name, args.build_type)
|
||||||
|
|
||||||
perftest.createTables()
|
|
||||||
perftest.run()
|
perftest.run()
|
|
@ -20,12 +20,14 @@ import argparse
|
||||||
|
|
||||||
|
|
||||||
class taosdemoQueryPerformace:
|
class taosdemoQueryPerformace:
|
||||||
def __init__(self, clearCache, commitID, dbName, stbName, tbPerfix):
|
def __init__(self, clearCache, commitID, dbName, stbName, tbPerfix, branch, type):
|
||||||
self.clearCache = clearCache
|
self.clearCache = clearCache
|
||||||
self.commitID = commitID
|
self.commitID = commitID
|
||||||
self.dbName = dbName
|
self.dbName = dbName
|
||||||
self.stbName = stbName
|
self.stbName = stbName
|
||||||
self.tbPerfix = tbPerfix
|
self.tbPerfix = tbPerfix
|
||||||
|
self.branch = branch
|
||||||
|
self.type = type
|
||||||
self.host = "127.0.0.1"
|
self.host = "127.0.0.1"
|
||||||
self.user = "root"
|
self.user = "root"
|
||||||
self.password = "taosdata"
|
self.password = "taosdata"
|
||||||
|
@ -35,50 +37,56 @@ class taosdemoQueryPerformace:
|
||||||
self.user,
|
self.user,
|
||||||
self.password,
|
self.password,
|
||||||
self.config)
|
self.config)
|
||||||
|
self.host2 = "192.168.1.179"
|
||||||
|
self.conn2 = taos.connect(
|
||||||
|
host = self.host2,
|
||||||
|
user = self.user,
|
||||||
|
password = self.password,
|
||||||
|
config = self.config)
|
||||||
|
|
||||||
def createPerfTables(self):
|
def createPerfTables(self):
|
||||||
cursor = self.conn.cursor()
|
cursor2 = self.conn2.cursor()
|
||||||
cursor.execute("create database if not exists %s" % self.dbName)
|
cursor2.execute("create database if not exists %s" % self.dbName)
|
||||||
cursor.execute("use %s" % self.dbName)
|
cursor2.execute("use %s" % self.dbName)
|
||||||
cursor.execute("create table if not exists %s(ts timestamp, query_time float, commit_id binary(50)) tags(query_id int, query_sql binary(300))" % self.stbName)
|
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)
|
||||||
|
|
||||||
sql = "select count(*) from test.meters"
|
sql = "select count(*) from test.meters"
|
||||||
tableid = 1
|
tableid = 1
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select avg(f1), max(f2), min(f3) from test.meters"
|
sql = "select avg(f1), max(f2), min(f3) from test.meters"
|
||||||
tableid = 2
|
tableid = 2
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select count(*) from test.meters where loc='beijing'"
|
sql = "select count(*) from test.meters where loc='beijing'"
|
||||||
tableid = 3
|
tableid = 3
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10"
|
sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10"
|
||||||
tableid = 4
|
tableid = 4
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)"
|
sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)"
|
||||||
tableid = 5
|
tableid = 5
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select last_row(*) from meters"
|
sql = "select last_row(*) from meters"
|
||||||
tableid = 6
|
tableid = 6
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
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"
|
||||||
tableid = 7
|
tableid = 7
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'"
|
sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'"
|
||||||
tableid = 8
|
tableid = 8
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
sql = "select last(*) from meters"
|
sql = "select last(*) from meters"
|
||||||
tableid = 9
|
tableid = 9
|
||||||
cursor.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql))
|
||||||
|
|
||||||
cursor.close()
|
cursor2.close()
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
cursor = self.conn.cursor()
|
cursor = self.conn.cursor()
|
||||||
|
@ -106,8 +114,8 @@ class taosdemoQueryPerformace:
|
||||||
cursor2.close()
|
cursor2.close()
|
||||||
print("query time for: %s %f seconds" % (sql, totalTime / 100))
|
print("query time for: %s %f seconds" % (sql, totalTime / 100))
|
||||||
|
|
||||||
cursor3 = self.conn.cursor()
|
cursor3 = self.conn2.cursor()
|
||||||
cursor3.execute("insert into %s.%s values(now, %f, '%s')" % (self.dbName, table_name, totalTime / 100, self.commitID))
|
cursor3.execute("insert into %s.%s values(now, %f, '%s', '%s', '%s')" % (self.dbName, table_name, totalTime / 100, self.commitID, self.branch, self.type))
|
||||||
|
|
||||||
cursor3.close()
|
cursor3.close()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
@ -148,8 +156,22 @@ if __name__ == '__main__':
|
||||||
default='q',
|
default='q',
|
||||||
type=str,
|
type=str,
|
||||||
help='table name perfix (default: q)')
|
help='table name perfix (default: q)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-b',
|
||||||
|
'--git-branch',
|
||||||
|
action='store',
|
||||||
|
default='master',
|
||||||
|
type=str,
|
||||||
|
help='git branch (default: master)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-T',
|
||||||
|
'--build-type',
|
||||||
|
action='store',
|
||||||
|
default='glibc',
|
||||||
|
type=str,
|
||||||
|
help='build type (default: glibc)')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
perftest = taosdemoQueryPerformace(args.remove_cache, args.commit_id, args.database_name, args.stable_name, args.table_perfix)
|
perftest = taosdemoQueryPerformace(args.remove_cache, args.commit_id, args.database_name, args.stable_name, args.table_perfix, args.git_branch, args.build_type)
|
||||||
perftest.createPerfTables()
|
perftest.createPerfTables()
|
||||||
perftest.query()
|
perftest.query()
|
||||||
|
|
|
@ -20,9 +20,11 @@ from util.log import tdLog
|
||||||
from util.sql import tdSql
|
from util.sql import tdSql
|
||||||
|
|
||||||
class taosdemoPerformace:
|
class taosdemoPerformace:
|
||||||
def __init__(self, commitID, dbName):
|
def __init__(self, commitID, dbName, branch, type):
|
||||||
self.commitID = commitID
|
self.commitID = commitID
|
||||||
self.dbName = dbName
|
self.dbName = dbName
|
||||||
|
self.branch = branch
|
||||||
|
self.type = type
|
||||||
self.host = "127.0.0.1"
|
self.host = "127.0.0.1"
|
||||||
self.user = "root"
|
self.user = "root"
|
||||||
self.password = "taosdata"
|
self.password = "taosdata"
|
||||||
|
@ -33,6 +35,12 @@ class taosdemoPerformace:
|
||||||
self.password,
|
self.password,
|
||||||
self.config)
|
self.config)
|
||||||
self.insertDB = "insertDB"
|
self.insertDB = "insertDB"
|
||||||
|
self.host2 = "192.168.1.179"
|
||||||
|
self.conn2 = taos.connect(
|
||||||
|
host = self.host2,
|
||||||
|
user = self.user,
|
||||||
|
password = self.password,
|
||||||
|
config = self.config)
|
||||||
|
|
||||||
def generateJson(self):
|
def generateJson(self):
|
||||||
db = {
|
db = {
|
||||||
|
@ -122,12 +130,9 @@ class taosdemoPerformace:
|
||||||
return buildPath
|
return buildPath
|
||||||
|
|
||||||
def insertData(self):
|
def insertData(self):
|
||||||
|
|
||||||
buildPath = self.getBuildPath()
|
buildPath = self.getBuildPath()
|
||||||
if (buildPath == ""):
|
if (buildPath == ""):
|
||||||
tdLog.exit("taosdemo not found!")
|
tdLog.exit("taosdemo not found!")
|
||||||
else:
|
|
||||||
tdLog.info("taosdemo found in %s" % buildPath)
|
|
||||||
binPath = buildPath + "/build/bin/"
|
binPath = buildPath + "/build/bin/"
|
||||||
|
|
||||||
os.system(
|
os.system(
|
||||||
|
@ -153,11 +158,11 @@ class taosdemoPerformace:
|
||||||
os.system("[ -f taosdemoperf.txt ] && rm taosdemoperf.txt")
|
os.system("[ -f taosdemoperf.txt ] && rm taosdemoperf.txt")
|
||||||
|
|
||||||
def createTablesAndStoreData(self):
|
def createTablesAndStoreData(self):
|
||||||
cursor = self.conn.cursor()
|
cursor = self.conn2.cursor()
|
||||||
|
|
||||||
cursor.execute("create database if not exists %s" % self.dbName)
|
cursor.execute("create database if not exists %s" % self.dbName)
|
||||||
cursor.execute("use %s" % self.dbName)
|
cursor.execute("use %s" % self.dbName)
|
||||||
cursor.execute("create table if not exists taosdemo_perf (ts timestamp, create_table_time float, insert_records_time float, records_per_second float, commit_id binary(50), avg_delay float, max_delay float, min_delay float)")
|
cursor.execute("create table if not exists taosdemo_perf (ts timestamp, create_table_time float, insert_records_time float, records_per_second float, commit_id binary(50), avg_delay float, max_delay float, min_delay float, branch binary(50), type binary(20))")
|
||||||
print("==================== taosdemo performance ====================")
|
print("==================== taosdemo performance ====================")
|
||||||
print("create tables time: %f" % float(self.createTableTime))
|
print("create tables time: %f" % float(self.createTableTime))
|
||||||
print("insert records time: %f" % float(self.insertRecordsTime))
|
print("insert records time: %f" % float(self.insertRecordsTime))
|
||||||
|
@ -165,19 +170,14 @@ class taosdemoPerformace:
|
||||||
print("avg delay: %f" % float(self.avgDelay))
|
print("avg delay: %f" % float(self.avgDelay))
|
||||||
print("max delay: %f" % float(self.maxDelay))
|
print("max delay: %f" % float(self.maxDelay))
|
||||||
print("min delay: %f" % float(self.minDelay))
|
print("min delay: %f" % float(self.minDelay))
|
||||||
cursor.execute(
|
cursor.execute("insert into taosdemo_perf values(now, %f, %f, %f, '%s', %f, %f, %f, '%s', '%s')" %
|
||||||
"insert into taosdemo_perf values(now, %f, %f, %f, '%s', %f, %f, %f)" %
|
(float(self.createTableTime), float(self.insertRecordsTime), float(self.recordsPerSecond),
|
||||||
(float(
|
self.commitID, float(self.avgDelay), float(self.maxDelay), float(self.minDelay), self.branch, self.type))
|
||||||
self.createTableTime), float(
|
|
||||||
self.insertRecordsTime), float(
|
|
||||||
self.recordsPerSecond), self.commitID, float(
|
|
||||||
self.avgDelay), float(
|
|
||||||
self.maxDelay), float(
|
|
||||||
self.minDelay)))
|
|
||||||
cursor.execute("drop database if exists %s" % self.insertDB)
|
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
cursor1 = self.conn.cursor()
|
||||||
|
cursor1.execute("drop database if exists %s" % self.insertDB)
|
||||||
|
cursor1.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
@ -194,9 +194,22 @@ if __name__ == '__main__':
|
||||||
default='perf',
|
default='perf',
|
||||||
type=str,
|
type=str,
|
||||||
help='Database name to be created (default: perf)')
|
help='Database name to be created (default: perf)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-b',
|
||||||
|
'--git-branch',
|
||||||
|
action='store',
|
||||||
|
default='master',
|
||||||
|
type=str,
|
||||||
|
help='git branch (default: master)')
|
||||||
|
parser.add_argument(
|
||||||
|
'-T',
|
||||||
|
'--build-type',
|
||||||
|
action='store',
|
||||||
|
default='glibc',
|
||||||
|
type=str,
|
||||||
|
help='build type (default: glibc)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
perftest = taosdemoPerformace(args.commit_id, args.database_name)
|
perftest = taosdemoPerformace(args.commit_id, args.database_name, args.git_branch, args.build_type)
|
||||||
perftest.insertData()
|
perftest.insertData()
|
||||||
perftest.createTablesAndStoreData()
|
perftest.createTablesAndStoreData()
|
||||||
|
|
Loading…
Reference in New Issue