Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.perf / lib / perftest / testresult.py
CommitLineData
88b9d363 1# Copyright (C) 2013-2022 Free Software Foundation, Inc.
f27a1236
YQ
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
13123da8 16
f27a1236
YQ
17class TestResult(object):
18 """Base class to record and report test results.
19
20 Method record is to record the results of test case, and report
21 method is to report the recorded results by a given reporter.
22 """
23
24 def record(self, parameter, result):
25 raise NotImplementedError("Abstract Method:record.")
26
27 def report(self, reporter, name):
28 """Report the test results by reporter."""
29 raise NotImplementedError("Abstract Method:report.")
30
13123da8 31
f27a1236
YQ
32class SingleStatisticTestResult(TestResult):
33 """Test results for the test case with a single statistic."""
34
35 def __init__(self):
13123da8
SM
36 super(SingleStatisticTestResult, self).__init__()
37 self.results = dict()
f27a1236
YQ
38
39 def record(self, parameter, result):
af061d3e
DE
40 if parameter in self.results:
41 self.results[parameter].append(result)
42 else:
43 self.results[parameter] = [result]
f27a1236
YQ
44
45 def report(self, reporter, name):
46 reporter.start()
582a1b00 47 for key in sorted(self.results.keys()):
f27a1236
YQ
48 reporter.report(name, key, self.results[key])
49 reporter.end()
50
13123da8 51
f27a1236
YQ
52class ResultFactory(object):
53 """A factory to create an instance of TestResult."""
54
55 def create_result(self):
56 """Create an instance of TestResult."""
57 raise NotImplementedError("Abstract Method:create_result.")
58
13123da8 59
f27a1236
YQ
60class SingleStatisticResultFactory(ResultFactory):
61 """A factory to create an instance of SingleStatisticTestResult."""
62
63 def create_result(self):
64 return SingleStatisticTestResult()
This page took 0.966521 seconds and 4 git commands to generate.