Adding a few more functions to get php version, driver version, msodbcsql version

This commit is contained in:
ulvii 2017-06-28 17:54:18 -07:00
parent 0ce6fc52a2
commit 1e3c1c8dcc

View file

@ -54,11 +54,13 @@ class XMLResult( object ):
, success = None
, duration = None
, memory = None
, iterations = None
, error_message = None ):
self.benchmark_name = benchmark_name
self.success = success
self.duration = duration
self.memory = memory
self.iterations = iterations
self.error_message = error_message
def get_test_name( name ):
@ -242,6 +244,11 @@ def get_php_arch():
elif out.decode('ascii') == "4":
return "x86"
def get_php_version():
p = subprocess.Popen( "php -r 'echo phpversion();'", stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
return out.decode('ascii')
def get_php_thread():
if os.name == 'nt':
command = "php -i | findstr 'Thread'"
@ -254,6 +261,19 @@ def get_php_thread():
else:
return "ts"
def get_driver_version( driver_name ):
command = "php -r \"echo phpversion('{0}');\""
print(command.format( driver_name ))
p = subprocess.Popen( command.format( driver_name ), stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
return out.decode('ascii')
def get_msodbcsql_version( test_db ):
command = "php -r \"echo sqlsrv_client_info( sqlsrv_connect( '{0}', array( 'UID'=>'{1}', 'PWD'=>'{2}')))['DriverName'];\""
p = subprocess.Popen( command.format( test_db.server_name, test_db.username, test_db.password ), stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
return out.decode('ascii')
def get_path_to_driver( driver_name ):
p = subprocess.Popen( "php -r \"echo ini_get('extension_dir');\"", stdout=subprocess.PIPE, shell = True )
out, err = p.communicate()
@ -309,17 +329,18 @@ def disable_pooling():
def run_tests( iterations, iterations_large ):
print("Running the tests...")
call( get_run_command( sqlsrv_regular_path, iterations, "sqlsrv-regular.xml" ), shell=True, stdout=open( os.devnull, 'wb' ))
call( get_run_command( sqlsrv_large_path, iterations_large, "sqlsrv-large.xml" ), shell=True, stdout=open( os.devnull, 'wb' ))
call( get_run_command( sqlsrv_regular_path, iterations, "sqlsrv-regular.xml" ), shell=True )
call( get_run_command( sqlsrv_large_path, iterations_large, "sqlsrv-large.xml" ), shell=True )
call( get_run_command( pdo_regular_path, iterations, "pdo_sqlsrv-regular.xml" ), shell=True, stdout=open( os.devnull, 'wb' ))
call( get_run_command( pdo_large_path, iterations_large, "pdo_sqlsrv-large.xml" ), shell=True, stdout=open( os.devnull, 'wb' ))
call( get_run_command( pdo_regular_path, iterations, "pdo_sqlsrv-regular.xml" ), shell=True )
call( get_run_command( pdo_large_path, iterations_large, "pdo_sqlsrv-large.xml" ), shell=True )
def parse_results( dump_file ):
xml_results = []
tree = ET.parse( dump_file )
root = tree.getroot()
for benchmark in root[0].findall( 'benchmark' ):
benchmarks = root[0].findall( 'benchmark' )
for benchmark in benchmarks:
xml_result = XMLResult()
xml_result.benchmark_name = benchmark.get( 'class' )[1:]
errors = benchmark[0][0].find( 'errors' )
@ -329,8 +350,10 @@ def parse_results( dump_file ):
else:
xml_result.success = 1
xml_result.duration = int( round( int( benchmark[0][0].find( 'stats' ).get( 'sum' )) / 1000000 ))
iterations = benchmark[0][0].findall( 'iteration' )
xml_result.iterations = len( iterations )
memory_peak = 0
for iteration in benchmark[0][0].findall( 'iteration' ):
for iteration in iterations:
iter_memory_peak = int( iteration.get( 'mem-peak' ))
if iter_memory_peak > memory_peak:
memory_peak = iter_memory_peak
@ -347,8 +370,13 @@ def parse_and_store_results( dump_file, test_db, result_db, platform, driver, st
team_id = get_team_id( conn )
driver_id = get_driver_id( conn, driver )
arch = get_php_arch()
thread = get_php_thread()
php_arch = get_php_arch()
php_thread = get_php_thread()
php_version = get_php_version()
driver_version = get_driver_version( driver )
msodbcsql_version = get_msodbcsql_version( test_db )
cursor = conn.cursor()
results = parse_results( dump_file )
@ -358,18 +386,21 @@ def parse_and_store_results( dump_file, test_db, result_db, platform, driver, st
result_id = insert_result_entry_and_get_id( conn, test_id, client_id, driver_id, server_id, team_id, result.success )
if result.success:
insert_key_value( conn, "KeyValueTableBigInt", result_id, "duration", result.duration )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "memory", result.memory )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "duration", result.duration )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "memory", result.memory )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "iterations", result.iterations)
else:
insert_key_value( conn, "KeyValueTableString", result_id, "error", result.error_message )
insert_key_value( conn, "KeyValueTableDate" , result_id, "startTime", start_time )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "mars" , mars )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "pooling" , pooling )
insert_key_value( conn, "KeyValueTableString", result_id, "driver" , driver )
insert_key_value( conn, "KeyValueTableString", result_id, "arch" , arch )
insert_key_value( conn, "KeyValueTableString", result_id, "os" , platform )
insert_key_value( conn, "KeyValueTableString", result_id, "thread" , thread )
insert_key_value( conn, "KeyValueTableDate" , result_id, "startTime" , start_time )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "mars" , mars )
insert_key_value( conn, "KeyValueTableBigInt", result_id, "pooling" , pooling )
insert_key_value( conn, "KeyValueTableString", result_id, "driver" , driver )
insert_key_value( conn, "KeyValueTableString", result_id, "php_arch" , php_arch )
insert_key_value( conn, "KeyValueTableString", result_id, "os" , platform )
insert_key_value( conn, "KeyValueTableString", result_id, "php_thread" , php_thread )
insert_key_value( conn, "KeyValueTableString", result_id, "php_version", php_version )
insert_key_value( conn, "KeyValueTableString", result_id, "msodbcsql" , msodbcsql_version )
def parse_and_store_results_all( test_db, result_db, platform, start_time, mars, pooling ):
print("Parsing and storing the results...")
@ -414,3 +445,4 @@ if __name__ == '__main__':
parse_and_store_results_all( test_db, result_db, args.PLATFORM, start_time, 0, 1 )
disable_pooling()