From b0041fc30192e07fb0757f23f289a10d0e4e31e2 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 7 Jul 2019 17:39:57 +0000 Subject: [PATCH] add benchcompare script Signed-off-by: Ivailo Monev --- scripts/benchcompare.py | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 scripts/benchcompare.py diff --git a/scripts/benchcompare.py b/scripts/benchcompare.py new file mode 100755 index 000000000..bd6832aae --- /dev/null +++ b/scripts/benchcompare.py @@ -0,0 +1,84 @@ +#!/usr/bin/python + +import os, sys, subprocess +import xml.etree.ElementTree as ET + +if len(sys.argv) < 3: + print("usage: ") + sys.exit(1) + +commonargs = ['-iterations', '1000', '-tickcounter', '-xml'] +katieargs = [sys.argv[1], '-o', '/tmp/katie-bench.xml'] +qt4args = [sys.argv[2], '-o', '/tmp/qt4-bench.xml'] +katieargs.extend(commonargs) +qt4args.extend(commonargs) + +print('Running Katie benchmark..') +subprocess.check_call(katieargs) + +print('Running Qt4 benchmark..') +subprocess.check_call(qt4args) + +print('Parsing benchmark results..') +katiemap = {} +tree = ET.parse('/tmp/katie-bench.xml') +root = tree.getroot() +for testfunc in root: + for testresult in testfunc: + tag = testresult.get('tag') + if not tag: + continue + value = testresult.get('value') + katiemap[tag] = value + +qt4map = {} +tree = ET.parse('/tmp/qt4-bench.xml') +root = tree.getroot() +for testfunc in root: + for testresult in testfunc: + tag = testresult.get('tag') + if not tag: + continue + value = testresult.get('value') + qt4map[tag] = value + +print('Comparing benchmark results..') +tagmax = 0 +for ktag in katiemap: + if not ktag in qt4map: + continue + taglen = len(ktag) + if taglen > tagmax: + tagmax = taglen + +infomax = (tagmax + 30) +infoalign = (tagmax - 2) +print('*' * infomax) +print(' Tag%s* Ticks Katie/Qt4 (Winner) *' % (' ' * infoalign)) +print('*' * infomax) +ktotal = 0 +qtotal = 0 +for ktag in katiemap: + if not ktag in qt4map: + # print(' filtering Katie tag: %s' % tag) + continue + kvalue = katiemap[ktag] + ikvalue = int(kvalue) + qvalue = qt4map[ktag] + iqvalue = int(qvalue) + tagalign = tagmax - len(ktag) + 1 + winner = 'Katie' + if ikvalue > iqvalue: + winner = 'Qt4' + ktotal += ikvalue + qtotal += iqvalue + print(' %s%s: %d/%d (%s)' % (ktag, ' ' * tagalign, ikvalue, iqvalue, winner)) + +totalalign = (tagmax - 3) +totalwinner = 'Katie' +if ktotal > qtotal: + totalwinner = 'Qt4' +print('') +print('*' * infomax) +print('Total%s: %d/%d (%s)' % (' ' * totalalign, ktotal, qtotal, winner)) +print('*' * infomax)