From a1a431178f52d1b7b8b24ea2851b509627ddb89d Mon Sep 17 00:00:00 2001 From: Zhizhou Yang Date: Thu, 28 Feb 2019 17:32:13 -0800 Subject: crosperf: replace cpu cycles in report with samples What we collected from benchmark run actually are samples from perf tool, so "cpu cycles" is not a accurate name. BUG=chromium:936573 TEST=Tested with cwp and general mode on eve; Passed all unittests. Change-Id: I35533cea0987c4e1b112498cc1b0271eaab665ae Reviewed-on: https://chromium-review.googlesource.com/1495963 Commit-Ready: Zhizhou Yang Tested-by: Zhizhou Yang Reviewed-by: Caroline Tice --- cros_utils/tabulator_test.py | 75 ++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 24 deletions(-) (limited to 'cros_utils/tabulator_test.py') diff --git a/cros_utils/tabulator_test.py b/cros_utils/tabulator_test.py index 6d3ff55c..943d9349 100644 --- a/cros_utils/tabulator_test.py +++ b/cros_utils/tabulator_test.py @@ -1,4 +1,7 @@ -# Copyright 2012 Google Inc. All Rights Reserved. +# -*- coding: utf-8 -*- +# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. """Tests for the tabulator module.""" from __future__ import print_function @@ -71,13 +74,19 @@ class TabulatorTest(unittest.TestCase): self.assertTrue(b >= 0.99e+308 and b <= 1.01e+308) def testTableGenerator(self): - runs = [[{'k1': '10', - 'k2': '12'}, {'k1': '13', - 'k2': '14', - 'k3': '15'}], [{'k1': '50', - 'k2': '51', - 'k3': '52', - 'k4': '53'}]] + runs = [[{ + 'k1': '10', + 'k2': '12' + }, { + 'k1': '13', + 'k2': '14', + 'k3': '15' + }], [{ + 'k1': '50', + 'k2': '51', + 'k3': '52', + 'k4': '53' + }]] labels = ['vanilla', 'modified'] tg = tabulator.TableGenerator(runs, labels) table = tg.GetTable() @@ -103,16 +112,29 @@ class TabulatorTest(unittest.TestCase): table = tf.GetCellTable() self.assertTrue(table) - def testCPUCyclesTableGenerator(self): - keyvals = {'bench1': [[{'cpu_cycles': 1}, {'cpu_cycles': 2}], - [{'cpu_cycles': 3}, {'cpu_cycles': 4}]], - 'bench2': [[{'cpu_cycles': 5}, {}], - [{'cpu_cycles': 6}, {'cpu_cycles': 7}]]} + def testSamplesTableGenerator(self): + keyvals = { + 'bench1': [[{ + 'samples': 1 + }, { + 'samples': 2 + }], [{ + 'samples': 3 + }, { + 'samples': 4 + }]], + 'bench2': [[{ + 'samples': 5 + }, {}], [{ + 'samples': 6 + }, { + 'samples': 7 + }]] + } weights = {'bench1': 0.2, 'bench2': 0.7} iter_counts = {'bench1': 2, 'bench2': 2} labels = ['vanilla', 'modified'] - tg = tabulator.CPUCyclesTableGenerator(keyvals, labels, iter_counts, - weights) + tg = tabulator.SamplesTableGenerator(keyvals, labels, iter_counts, weights) (table, new_keyvals, new_iter_counts) = tg.GetTable() columns = [ @@ -122,7 +144,7 @@ class TabulatorTest(unittest.TestCase): tabulator.PercentFormat()), ] # This is the function to load column info. - tf = tabulator.TableFormatter(table, columns, cpu_table=True) + tf = tabulator.TableFormatter(table, columns, samples_table=True) # This is the function where to do all weighting calculation. cell_table = tf.GetCellTable('summary') self.assertTrue(cell_table) @@ -130,20 +152,25 @@ class TabulatorTest(unittest.TestCase): header = table.pop(0) self.assertTrue(header == ['Benchmarks', 'Weights', 'vanilla', 'modified']) row = table.pop(0) - self.assertTrue(row == ['bench1', 0.2, ((2, 0), [1*0.2, 2*0.2]), - ((2, 0), [3*0.2, 4*0.2])]) + self.assertTrue(row == [ + 'bench1', 0.2, ((2, 0), [1 * 0.2, 2 * 0.2]), ((2, 0), + [3 * 0.2, 4 * 0.2]) + ]) row = table.pop(0) - self.assertTrue(row == ['bench2', 0.7, ((1, 1), [5*0.7, None]), - ((2, 0), [6*0.7, 7*0.7])]) + self.assertTrue(row == [ + 'bench2', 0.7, ((1, 1), [5 * 0.7, None]), ((2, 0), [6 * 0.7, 7 * 0.7]) + ]) row = table.pop(0) - self.assertTrue(row == ['Composite Benchmark (cycles)', 'N/A', - ((1, 1), [1*0.2+5*0.7, None]), - ((2, 0), [3*0.2+6*0.7, 4*0.2+7*0.7])]) + self.assertTrue(row == [ + 'Composite Benchmark (samples)', 'N/A', + ((1, 1), + [1 * 0.2 + + 5 * 0.7, None]), ((2, 0), [3 * 0.2 + 6 * 0.7, 4 * 0.2 + 7 * 0.7]) + ]) self.assertTrue('Composite Benchmark' in new_keyvals.keys()) self.assertTrue('Composite Benchmark' in new_iter_counts.keys()) - def testColspan(self): simple_table = [ ['binary', 'b1', 'b2', 'b3'], -- cgit v1.2.3