From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9977 invoked by alias); 28 Aug 2013 09:57:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9966 invoked by uid 89); 28 Aug 2013 09:57:36 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2013 09:57:36 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RDNS_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mga14.intel.com Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 28 Aug 2013 02:57:31 -0700 X-ExtLoop1: 1 Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by AZSMGA002.ch.intel.com with ESMTP; 28 Aug 2013 02:57:30 -0700 Received: from irsmsx152.ger.corp.intel.com (163.33.192.66) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 28 Aug 2013 10:57:29 +0100 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.64]) by IRSMSX152.ger.corp.intel.com ([169.254.6.33]) with mapi id 14.03.0123.003; Wed, 28 Aug 2013 10:57:29 +0100 From: "Agovic, Sanimir" To: 'Yao Qi' , "gdb-patches@sourceware.org" Subject: RE: [RFC 2/3] Perf test framework Date: Wed, 28 Aug 2013 09:57:00 -0000 Message-ID: <0377C58828D86C4588AEEC42FC3B85A71765866D@IRSMSX105.ger.corp.intel.com> References: <520B7F70.6070207@codesourcery.com> <1377663394-4975-1-git-send-email-yao@codesourcery.com> <1377663394-4975-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1377663394-4975-3-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-08/txt/msg00815.txt.bz2 lgtm, however I cannot approve your patch. Some optional comments below. -Sanimir > -----Original Message----- > From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourcewa= re.org] On Behalf > Of Yao Qi > Sent: Wednesday, August 28, 2013 06:17 AM > To: gdb-patches@sourceware.org > Subject: [RFC 2/3] Perf test framework >=20 > --- > gdb/testsuite/gdb.perf/lib/perftest/config.py | 40 +++++++++++++++= ++ > gdb/testsuite/gdb.perf/lib/perftest/perftest.py | 49 +++++++++++++++= ++++++ > gdb/testsuite/gdb.perf/lib/perftest/reporter.py | 38 ++++++++++++++++ > gdb/testsuite/gdb.perf/lib/perftest/testresult.py | 42 +++++++++++++++= +++ > I would put a copyright header and a module __doc__ into __init__.py > diff --git a/gdb/testsuite/gdb.perf/lib/perftest/perftest.py > b/gdb/testsuite/gdb.perf/lib/perftest/perftest.py > new file mode 100644 > index 0000000..b15fd39 > --- /dev/null > +++ b/gdb/testsuite/gdb.perf/lib/perftest/perftest.py > @@ -0,0 +1,49 @@ [...] > + > +class TestCase(gdb.Function): > + """Base class of all performance testing cases. It registers a GDB > + convenience function 'perftest'. Invoke this convenience function > + in GDB will call method 'invoke'.""" > + > + def __init__(self, result): > + # Each test case registers a convenience function 'perftest'. > + super (TestCase, self).__init__ ("perftest") > + self.result =3D result > + > + def execute_test(self): > + """Abstract method to do the actual tests.""" > + raise RuntimeError("Abstract Method.") > You may use module abc instead: | class TestCase(gdb.Function): | __metaclass__ =3D abc.ABCMeta | @abc.abstractmethod | def execute_test(self): pass Instantiating TestCase and subclasses without overriding execute_test will = fail. > diff --git a/gdb/testsuite/gdb.perf/lib/perftest/reporter.py > b/gdb/testsuite/gdb.perf/lib/perftest/reporter.py > new file mode 100644 > index 0000000..e27b2ae > --- /dev/null > +++ b/gdb/testsuite/gdb.perf/lib/perftest/reporter.py > @@ -0,0 +1,38 @@ > +# Copyright (C) 2013 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +class Reporter(object): > + """Base class of reporter, which is about reporting test results in > + different formatss.""" > + > + def report(self, arg1, arg2, arg3): > Using *args should handle most cases well. > + raise RuntimeError("Abstract Method.") > + > + def end(self): > + """Invoked when reporting is done. Usually it can be overridden > + to do some cleanups, such as closing file descriptors.""" > + raise RuntimeError("Abstract Method:end.") > The doc state _can be overridden_ thus you should provide a default impleme= ntation instead of raising an exception, or write _must be overridden_. > + > +class TextReporter(Reporter): > + """Report results in plain text 'perftest.log'.""" > + > + def __init__(self): > + self.txt_log =3D open ("perftest.log", 'a+'); > + > + def report(self, arg1, arg2, arg3): > + print >>self.txt_log, '%s %s %s' % (arg1, arg2, arg3) > Afaik >> is deprecated, self.txt_log.write(' '.join(args)) > + > + def end(self): > + self.txt_log.close () > diff --git a/gdb/testsuite/gdb.perf/lib/perftest/testresult.py > b/gdb/testsuite/gdb.perf/lib/perftest/testresult.py > new file mode 100644 > index 0000000..9912326 > --- /dev/null > +++ b/gdb/testsuite/gdb.perf/lib/perftest/testresult.py > @@ -0,0 +1,42 @@ [...] > + > +class SingleVariableTestResult(TestResult): > + """Test results for the test case with a single variable. """ > + > + def __init__(self, name): > + super (SingleVariableTestResult, self).__init__ (name) > + self.results =3D dict () > + > + def record(self, variable, result): > + self.results[variable] =3D result > + > + def report(self, reporter): > + for key in sorted(self.results.iterkeys()): > + reporter.report (self.name, key, self.results[key]) > + reporter.end () > You may use: for key,value in sorted(self.results.iteritems(), key=3Ditemge= tter(0)) -Sanimir Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052