[benchmark] LogParser: tab & space delimited logs

Added support for tab delimited and formatted log output (space aligned columns as output to console by Benchmark_Driver).
This commit is contained in:
Pavol Vaskovic
2018-08-13 17:31:06 +02:00
parent d0cdaee798
commit c60e223a3b
2 changed files with 27 additions and 3 deletions

View File

@@ -149,11 +149,15 @@ class LogParser(object):
# Parse lines like this
# #,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)
results_re = re.compile(r'(\d+,[ \t]*\w+,' +
','.join([r'[ \t]*[\d.]+'] * 6) + ')')
results_re = re.compile(r'(\d+[, \t]*\w+[, \t]*' +
r'[, \t]*'.join([r'[\d.]+'] * 6) +
r'[, \t]*[\d.]*)') # optional MAX_RSS(B)
def _append_result(self, result):
r = PerformanceTestResult(result.split(','))
columns = result.split(',')
if len(columns) < 8:
columns = result.split()
r = PerformanceTestResult(columns)
if self.samples:
r.all_samples = self.samples
self.results.append(r)

View File

@@ -186,6 +186,26 @@ Totals,269
self.assertTrue(isinstance(results[0], PerformanceTestResult))
self.assertEquals(results[0].name, 'BitCount')
def test_parse_results_tab_delimited(self):
log = '34\tBitCount\t20\t3\t4\t4\t0\t4'
parser = LogParser()
results = parser.parse_results(log.splitlines())
self.assertTrue(isinstance(results[0], PerformanceTestResult))
self.assertEquals(results[0].name, 'BitCount')
def test_parse_results_formatted_text(self):
"""Parse format that Benchmark_Driver prints to console"""
log = ("""
# TEST SAMPLES MIN(μs) MAX(μs) MEAN(μs) SD(μs) MEDIAN(μs) MAX_RSS(B)
3 Array2D 20 2060 2188 2099 0 2099 20915200
Totals 281 2693794 2882846 2748843 0 0 0""")
parser = LogParser()
results = parser.parse_results(log.splitlines()[1:]) # without 1st \n
self.assertTrue(isinstance(results[0], PerformanceTestResult))
r = results[0]
self.assertEquals(r.name, 'Array2D')
self.assertEquals(r.max_rss, 20915200)
def test_parse_results_verbose(self):
"""Parse multiple performance test results with 2 sample formats:
single line for N = 1; two lines for N > 1.