Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Agovic, Sanimir" <sanimir.agovic@intel.com>
To: 'Yao Qi' <yao@codesourcery.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Subject: RE: [RFC 2/3] Perf test framework
Date: Wed, 28 Aug 2013 09:57:00 -0000	[thread overview]
Message-ID: <0377C58828D86C4588AEEC42FC3B85A71765866D@IRSMSX105.ger.corp.intel.com> (raw)
In-Reply-To: <1377663394-4975-3-git-send-email-yao@codesourcery.com>

lgtm, however I cannot approve your patch.

Some optional comments below.

 -Sanimir

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.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
> 
> ---
>  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 = 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__ = 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 <http://www.gnu.org/licenses/>.
> +
> +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 implementation
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 = 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 = dict ()
> +
> +    def record(self, variable, result):
> +        self.results[variable] = 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=itemgetter(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


  reply	other threads:[~2013-08-28  9:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 13:01 [RFC] GDB performance testing infrastructure Yao Qi
2013-08-21 20:39 ` Tom Tromey
2013-08-27  6:21   ` Yao Qi
2013-08-27 13:49 ` Agovic, Sanimir
2013-08-28  3:04   ` Yao Qi
2013-09-19  0:36     ` Doug Evans
2013-08-28  4:17 ` [RFC 0/3] GDB Performance testing Yao Qi
2013-08-28  4:17   ` [RFC 1/3] New make target 'check-perf' and new dir gdb.perf Yao Qi
2013-08-28  9:40     ` Agovic, Sanimir
2013-09-19 17:47     ` Doug Evans
2013-09-20 19:00       ` Tom Tromey
2013-09-20 18:59     ` Tom Tromey
2013-08-28  4:17   ` [RFC 2/3] Perf test framework Yao Qi
2013-08-28  9:57     ` Agovic, Sanimir [this message]
2013-09-03  1:45       ` Yao Qi
2013-09-03  6:38         ` Agovic, Sanimir
2013-09-19 19:09     ` Doug Evans
2013-09-20  8:04       ` Yao Qi
2013-09-20 16:51         ` Doug Evans
2013-09-22  2:54           ` Yao Qi
2013-09-22 23:14             ` Doug Evans
2013-09-20 17:12         ` Doug Evans
2013-08-28  4:17   ` [RFC 3/3] Test on solib load and unload Yao Qi
2013-08-28  4:27     ` Yao Qi
2013-08-28 11:31       ` Agovic, Sanimir
2013-09-03  1:59         ` Yao Qi
2013-09-03  6:33           ` Agovic, Sanimir
2013-09-02 15:24       ` Blanc, Nicolas
2013-09-03  2:04         ` Yao Qi
2013-09-03  7:50           ` Blanc, Nicolas
2013-09-19 22:45       ` Doug Evans
2013-09-20 19:19         ` Tom Tromey
2013-10-05  0:34           ` Doug Evans
2013-10-07 16:31             ` Tom Tromey
2013-09-22  6:25         ` Yao Qi
2013-09-23  0:14           ` Doug Evans
2013-09-24  2:31             ` Yao Qi
2013-10-05  0:37               ` Doug Evans
2013-09-20 19:14       ` Tom Tromey
2013-09-19 17:25   ` [RFC 0/3] GDB Performance testing Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0377C58828D86C4588AEEC42FC3B85A71765866D@IRSMSX105.ger.corp.intel.com \
    --to=sanimir.agovic@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox