public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Test on disassemble
  2013-11-20  2:53 [PATCH 0/3] More perf test cases Yao Qi
@ 2013-11-20  2:52 ` Yao Qi
  2013-11-20 15:50   ` Agovic, Sanimir
  2013-11-22 18:29   ` Tom Tromey
  2013-11-20  2:53 ` [PATCH 2/3] Test on single step Yao Qi
  2013-11-20  2:59 ` [PATCH 3/3] Test on backtrace Yao Qi
  2 siblings, 2 replies; 13+ messages in thread
From: Yao Qi @ 2013-11-20  2:52 UTC (permalink / raw)
  To: gdb-patches

This patch adds a test case to test the performance of GDB doing
disassembly.

gdb/testsuite/

     * gdb.perf/disassemble.exp: New.
     * gdb.perf/disassemble.py: New.
---
 gdb/testsuite/gdb.perf/disassemble.exp |   56 ++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/disassemble.py  |   36 ++++++++++++++++++++
 2 files changed, 92 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.perf/disassemble.exp
 create mode 100644 gdb/testsuite/gdb.perf/disassemble.py

diff --git a/gdb/testsuite/gdb.perf/disassemble.exp b/gdb/testsuite/gdb.perf/disassemble.exp
new file mode 100644
index 0000000..6a2b2fd
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/disassemble.exp
@@ -0,0 +1,56 @@
+# 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/>.
+
+# This test case is to test the speed of GDB when it is doing disassemble
+# some large functions in GDB.
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+global GDB
+
+standard_testfile .c
+# Overwrite $binfile
+set binfile $GDB
+
+PerfTest::assemble {
+    # Don't have compilation step.
+    return 0
+} {
+    global srcdir subdir
+    global binfile
+
+    gdb_exit
+    gdb_start
+    # When GDB is debugging GDB, the prompt is changed to "(top-gdb) ".
+    # In order to avoid the confusion of pattern matching, set the
+    # gdb_prompt to '(top-gdb)'.
+
+    global gdb_prompt
+    set gdb_prompt "\[(\]top-gdb\[)\]"
+
+    gdb_test_no_output "set prompt \(top-gdb\) " ""
+
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load ${binfile}
+
+    if ![runto_main] {
+	return -1
+    }
+} {
+    gdb_test "python Disassemble\(\).run()"
+}
diff --git a/gdb/testsuite/gdb.perf/disassemble.py b/gdb/testsuite/gdb.perf/disassemble.py
new file mode 100644
index 0000000..b8e7dfc
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/disassemble.py
@@ -0,0 +1,36 @@
+# 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/>.
+
+from perftest import perftest
+from perftest import measure
+
+class Disassemble(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self):
+        super (Disassemble, self).__init__ ("disassemble")
+
+    def warm_up(self):
+        do_test_command = "disassemble ada_evaluate_subexp"
+        gdb.execute (do_test_command, False, True)
+
+    def _do_test(self, c):
+        for func in ["evaluate_subexp_standard", "handle_inferior_event", "c_parse_internal"]:
+            for i in range(c+1):
+                do_test_command = "disassemble %s" % func
+                gdb.execute (do_test_command, False, True)
+
+    def execute_test(self):
+        for i in range(3):
+            self.measure.measure(lambda: self._do_test(i), i)
+
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 0/3] More perf test cases
@ 2013-11-20  2:53 Yao Qi
  2013-11-20  2:52 ` [PATCH 1/3] Test on disassemble Yao Qi
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Yao Qi @ 2013-11-20  2:53 UTC (permalink / raw)
  To: gdb-patches

Hi,
This patch series add three perf test cases about disassembly, single
step and backtrac respectively.  They are the most frequently used
functionalities, so I write cases for them first.

Although symbol and symtab is one of the major sources of performance
regression, I don't write cases for it because I feel incompetent
writing cases on symbols, and I'd like to start from simple ones (such
as these three cases).

*** BLURB HERE ***

Yao Qi (3):
  Test on disassemble
  Test on single step
  Test on backtrace

 gdb/testsuite/gdb.perf/backtrace.c     |   54 ++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/backtrace.exp   |   66 ++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/backtrace.py    |   51 ++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/disassemble.exp |   56 +++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/disassemble.py  |   36 +++++++++++++++++
 gdb/testsuite/gdb.perf/single-step.c   |   35 +++++++++++++++++
 gdb/testsuite/gdb.perf/single-step.exp |   56 +++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/single-step.py  |   35 +++++++++++++++++
 8 files changed, 389 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.perf/backtrace.c
 create mode 100644 gdb/testsuite/gdb.perf/backtrace.exp
 create mode 100644 gdb/testsuite/gdb.perf/backtrace.py
 create mode 100644 gdb/testsuite/gdb.perf/disassemble.exp
 create mode 100644 gdb/testsuite/gdb.perf/disassemble.py
 create mode 100644 gdb/testsuite/gdb.perf/single-step.c
 create mode 100644 gdb/testsuite/gdb.perf/single-step.exp
 create mode 100644 gdb/testsuite/gdb.perf/single-step.py

-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/3] Test on single step
  2013-11-20  2:53 [PATCH 0/3] More perf test cases Yao Qi
  2013-11-20  2:52 ` [PATCH 1/3] Test on disassemble Yao Qi
@ 2013-11-20  2:53 ` Yao Qi
  2013-11-22 18:30   ` Tom Tromey
  2013-11-20  2:59 ` [PATCH 3/3] Test on backtrace Yao Qi
  2 siblings, 1 reply; 13+ messages in thread
From: Yao Qi @ 2013-11-20  2:53 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/

     * gdb.perf/single-step.c: New.
     * gdb.perf/single-step.exp: New.
     * gdb.perf/single-step.py: New.
---
 gdb/testsuite/gdb.perf/single-step.c   |   35 ++++++++++++++++++++
 gdb/testsuite/gdb.perf/single-step.exp |   56 ++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/single-step.py  |   35 ++++++++++++++++++++
 3 files changed, 126 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.perf/single-step.c
 create mode 100644 gdb/testsuite/gdb.perf/single-step.exp
 create mode 100644 gdb/testsuite/gdb.perf/single-step.py

diff --git a/gdb/testsuite/gdb.perf/single-step.c b/gdb/testsuite/gdb.perf/single-step.c
new file mode 100644
index 0000000..2510c69
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/single-step.c
@@ -0,0 +1,35 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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/>.  */
+
+volatile int flag = 1;
+
+int
+main (void)
+{
+  int i = 0;
+
+  while (flag)
+    {
+      double d;
+      float f;
+
+      i++;
+      d = i * 3.14;
+      f = d / 0.618;
+    }
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.perf/single-step.exp b/gdb/testsuite/gdb.perf/single-step.exp
new file mode 100644
index 0000000..ffabbee
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/single-step.exp
@@ -0,0 +1,56 @@
+# 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/>.
+
+# This test case is to test the speed of GDB when it is doing singe step.
+# There is one parameter in this test:
+#  - SINGLE_STEP_COUNT is the number of single step GDB performs.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+standard_testfile .c
+set executable $testfile
+set expfile $testfile.exp
+
+# make check-perf RUNTESTFLAGS='single-step.exp SINGLE_STEP_COUNT=300'
+if ![info exists SINGLE_STEP_COUNT] {
+    set SINGLE_STEP_COUNT 10000
+}
+
+PerfTest::assemble {
+    global srcdir subdir srcfile binfile
+
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" ${binfile} executable {debug}] != "" } {
+	return -1
+    }
+    return 0
+} {
+    global binfile
+    clean_restart $binfile
+
+    if ![runto_main] {
+	fail "Can't run to main"
+	return -1
+    }
+} {
+    global SINGLE_STEP_COUNT
+
+    gdb_test_no_output "python SingleStep\(${SINGLE_STEP_COUNT}\).run()"
+    # Terminate the loop.
+    gdb_test "set variable flag = 0"
+}
diff --git a/gdb/testsuite/gdb.perf/single-step.py b/gdb/testsuite/gdb.perf/single-step.py
new file mode 100644
index 0000000..7e6617e
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/single-step.py
@@ -0,0 +1,35 @@
+# 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/>.
+
+from perftest import perftest
+from perftest import measure
+
+class SingleStep (perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, step):
+        super (SingleStep, self).__init__ ("single-step")
+        self.step = step
+
+    def warm_up(self):
+        for i in range(0, self.step):
+            gdb.execute("stepi", False, True)
+
+    def _run(self, r):
+        for j in range(0, r):
+            gdb.execute("stepi", False, True)
+
+    def execute_test(self):
+        for i in range(1, 5):
+            func = lambda: self._run(i * self.step)
+            self.measure.measure(func, i * self.step)
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/3] Test on backtrace
  2013-11-20  2:53 [PATCH 0/3] More perf test cases Yao Qi
  2013-11-20  2:52 ` [PATCH 1/3] Test on disassemble Yao Qi
  2013-11-20  2:53 ` [PATCH 2/3] Test on single step Yao Qi
@ 2013-11-20  2:59 ` Yao Qi
  2013-11-22 18:55   ` Tom Tromey
  2 siblings, 1 reply; 13+ messages in thread
From: Yao Qi @ 2013-11-20  2:59 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/

	* gdb.perf/backtrace.c: New.
	* gdb.perf/backtrace.exp: New.
	* gdb.perf/backtrace.py: New.
---
 gdb/testsuite/gdb.perf/backtrace.c   |   54 +++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/backtrace.exp |   66 ++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/backtrace.py  |   51 ++++++++++++++++++++++++++
 3 files changed, 171 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.perf/backtrace.c
 create mode 100644 gdb/testsuite/gdb.perf/backtrace.exp
 create mode 100644 gdb/testsuite/gdb.perf/backtrace.py

diff --git a/gdb/testsuite/gdb.perf/backtrace.c b/gdb/testsuite/gdb.perf/backtrace.c
new file mode 100644
index 0000000..958a23f
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/backtrace.c
@@ -0,0 +1,54 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   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/>.  */
+
+struct s
+{
+  int a[256];
+  char c[256];
+};
+
+static void
+fun2 (void)
+{
+
+}
+
+static void
+fun1 (int i, int j, long k, struct s ss)
+{
+  /* Allocate local variables on stack.  */
+  struct s s1;
+
+  if (i < BACKTRACE_DEPTH)
+    fun1 (i + 1, j + 2, k - 1, ss);
+  else
+    {
+      int ii;
+
+      for (ii = 0; ii < 10; ii++)
+	fun2 ();
+    }
+}
+
+int
+main (void)
+{
+  struct s ss;
+
+  fun1 (0, 0, 200, ss);
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.perf/backtrace.exp b/gdb/testsuite/gdb.perf/backtrace.exp
new file mode 100644
index 0000000..53b06dd
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/backtrace.exp
@@ -0,0 +1,66 @@
+# 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/>.
+
+# This test case is to test the performance of GDB doing stack
+# backtrace.
+# There is one parameter in this test:
+#  - BACKTRACE_DEPTH is the number of innermost frames that command
+#    'bt' prints.
+
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+standard_testfile .c
+set executable $testfile
+set expfile $testfile.exp
+
+# make check-perf RUNTESTFLAGS='backtrace.exp BACKTRACE_DEPTH=1024'
+if ![info exists BACKTRACE_DEPTH] {
+    set BACKTRACE_DEPTH 64
+}
+
+PerfTest::assemble {
+    global BACKTRACE_DEPTH
+    global srcdir subdir srcfile
+
+    set compile_flags {debug}
+    lappend compile_flags "additional_flags=-DBACKTRACE_DEPTH=${BACKTRACE_DEPTH}"
+
+    if { [gdb_compile "$srcdir/$subdir/$srcfile" ${binfile} executable $compile_flags] != ""} {
+	return -1
+    }
+
+    return 0
+} {
+    global binfile
+
+    clean_restart $binfile
+
+    if ![runto_main] {
+	fail "Can't run to main"
+	return -1
+    }
+
+    gdb_breakpoint "fun2"
+    gdb_continue_to_breakpoint "fun2"
+} {
+    global BACKTRACE_DEPTH
+
+    gdb_test "python BackTrace\($BACKTRACE_DEPTH\).run()"
+
+}
diff --git a/gdb/testsuite/gdb.perf/backtrace.py b/gdb/testsuite/gdb.perf/backtrace.py
new file mode 100644
index 0000000..6cfd8c3
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/backtrace.py
@@ -0,0 +1,51 @@
+# 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/>.
+
+from perftest import perftest
+from perftest import measure
+
+class BackTrace (perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, depth):
+        super (BackTrace, self).__init__ ("backtrace")
+        self.depth = depth
+
+    def warm_up(self):
+        # Warm up.
+        gdb.execute ("bt", False, True)
+        gdb.execute ("bt", False, True)
+
+    def _do_test(self):
+        """Do backtrace multiple times."""
+        for j in range(1, 15):
+            do_test_command = "bt %d" % self.depth
+            gdb.execute (do_test_command, False, True)
+
+    def execute_test(self):
+
+        line_size = 2
+        for i in range(1, 12):
+            # Keep the total size of dcache unchanged, and increase the
+            # line-size in the loop.
+            line_size_command = "set dcache line-size %d" % (line_size)
+            size_command = "set dcache size %d" % (4096 * 64 / line_size)
+            # Cache is cleared by changing line-size or size.
+            gdb.execute (line_size_command)
+            gdb.execute (size_command)
+
+            func = lambda: self._do_test()
+
+            self.measure.measure(func, line_size)
+
+            line_size *= 2
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 1/3] Test on disassemble
  2013-11-20  2:52 ` [PATCH 1/3] Test on disassemble Yao Qi
@ 2013-11-20 15:50   ` Agovic, Sanimir
  2013-11-24  7:05     ` Yao Qi
  2013-11-22 18:29   ` Tom Tromey
  1 sibling, 1 reply; 13+ messages in thread
From: Agovic, Sanimir @ 2013-11-20 15:50 UTC (permalink / raw)
  To: 'Yao Qi', gdb-patches

Some minor comments below.

> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-owner@sourceware.org] On Behalf
> Of Yao Qi
> Sent: Wednesday, November 20, 2013 03:51 AM
> To: gdb-patches@sourceware.org
> Subject: [PATCH 1/3] Test on disassemble
> 
> 
> diff --git a/gdb/testsuite/gdb.perf/disassemble.exp
> b/gdb/testsuite/gdb.perf/disassemble.exp
> new file mode 100644
> index 0000000..6a2b2fd
> --- /dev/null
> +++ b/gdb/testsuite/gdb.perf/disassemble.exp
> @@ -0,0 +1,56 @@
> +
> +    gdb_reinitialize_dir $srcdir/$subdir
> +    gdb_load ${binfile}
> +
> +    if ![runto_main] {
>
How about an option to measure performance without a running inferior
e.g. exec on top of the target stack? This may eliminate some overhead.

Does opcode/ provide some kind of null-op disassembler we can
use instead of a real ISA? A simple gdb source change or compiler
upgrade could make comparative runs quite hard.

> diff --git a/gdb/testsuite/gdb.perf/disassemble.py b/gdb/testsuite/gdb.perf/disassemble.py
> new file mode 100644
> index 0000000..b8e7dfc
> --- /dev/null
> +++ b/gdb/testsuite/gdb.perf/disassemble.py
> @@ -0,0 +1,36 @@
> +# 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/>.
> +
> +from perftest import perftest
> +from perftest import measure
> +
I see no use of 'measure', is it still needed?

> +class Disassemble(perftest.TestCaseWithBasicMeasurements):
> +    def __init__(self):
> +        super (Disassemble, self).__init__ ("disassemble")
> +
> +    def warm_up(self):
> +        do_test_command = "disassemble ada_evaluate_subexp"
> +        gdb.execute (do_test_command, False, True)
> +
> +    def _do_test(self, c):
> +        for func in ["evaluate_subexp_standard", "handle_inferior_event",
> "c_parse_internal"]:
> +            for i in range(c+1):
> +                do_test_command = "disassemble %s" % func
>
You may move this to the outer loop. Please use _ if you do not use the value "i".

> +                gdb.execute (do_test_command, False, True)
> +
> +    def execute_test(self):
> +        for i in range(3):
> +            self.measure.measure(lambda: self._do_test(i), i)
> +
> --
> 1.7.7.6

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] Test on disassemble
  2013-11-20  2:52 ` [PATCH 1/3] Test on disassemble Yao Qi
  2013-11-20 15:50   ` Agovic, Sanimir
@ 2013-11-22 18:29   ` Tom Tromey
  2013-11-25  3:10     ` Yao Qi
  1 sibling, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2013-11-22 18:29 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> +    # When GDB is debugging GDB, the prompt is changed to "(top-gdb) ".
Yao> +    # In order to avoid the confusion of pattern matching, set the
Yao> +    # gdb_prompt to '(top-gdb)'.
Yao> +
Yao> +    global gdb_prompt
Yao> +    set gdb_prompt "\[(\]top-gdb\[)\]"

It seems to me that this sort of change ought to be undone after the
tests are complete.  Otherwise, it could affect subsequent tests.

To do that properly, you'll want to use "catch".  Or, if you want to
wrap it up "macro style" see with_test_prefix.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] Test on single step
  2013-11-20  2:53 ` [PATCH 2/3] Test on single step Yao Qi
@ 2013-11-22 18:30   ` Tom Tromey
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2013-11-22 18:30 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao>      * gdb.perf/single-step.c: New.
Yao>      * gdb.perf/single-step.exp: New.
Yao>      * gdb.perf/single-step.py: New.

Looks good to me.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/3] Test on backtrace
  2013-11-20  2:59 ` [PATCH 3/3] Test on backtrace Yao Qi
@ 2013-11-22 18:55   ` Tom Tromey
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2013-11-22 18:55 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> 	* gdb.perf/backtrace.c: New.
Yao> 	* gdb.perf/backtrace.exp: New.
Yao> 	* gdb.perf/backtrace.py: New.

Ok.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] Test on disassemble
  2013-11-20 15:50   ` Agovic, Sanimir
@ 2013-11-24  7:05     ` Yao Qi
  2013-11-25  9:17       ` Agovic, Sanimir
  0 siblings, 1 reply; 13+ messages in thread
From: Yao Qi @ 2013-11-24  7:05 UTC (permalink / raw)
  To: Agovic, Sanimir; +Cc: gdb-patches

On 11/20/2013 09:24 PM, Agovic, Sanimir wrote:
> How about an option to measure performance without a running inferior
> e.g. exec on top of the target stack? This may eliminate some overhead.
>

On target exec, GDB will read data from local executable file, which 
should be quite fast and it won't bring any performance issues.

We need a running inferior, so that GDB will read data from target, with 
some overhead of communication between GDB and target.  We'd like to 
measure the performance like that, and alarm if GDB becomes slow.

> Does opcode/ provide some kind of null-op disassembler we can
> use instead of a real ISA? A simple gdb source change or compiler
> upgrade could make comparative runs quite hard.

I don't know what kind of simple gdb source change may affect the 
result.  If gdb source changes affect the result to some extent, such as 
30%, such changes are what we want to monitor, right?

The process of disassemble is I/O intensive, so probably compiler 
upgrade has minor effects on the result.  On the other hand, we should 
avoid changing factors other than GDB itself when measuring GDB performance.

>> >+
>> >+from perftest import perftest
>> >+from perftest import measure
>> >+
> I see no use of 'measure', is it still needed?
>

No, I'll remove it from these three cases.

>> >+class Disassemble(perftest.TestCaseWithBasicMeasurements):
>> >+    def __init__(self):
>> >+        super (Disassemble, self).__init__ ("disassemble")
>> >+
>> >+    def warm_up(self):
>> >+        do_test_command = "disassemble ada_evaluate_subexp"
>> >+        gdb.execute (do_test_command, False, True)
>> >+
>> >+    def _do_test(self, c):
>> >+        for func in ["evaluate_subexp_standard", "handle_inferior_event",
>> >"c_parse_internal"]:
>> >+            for i in range(c+1):
>> >+                do_test_command = "disassemble %s" % func
>> >
> You may move this to the outer loop. Please use _ if you do not use the value "i".
>

Thanks for the tip.  I'll post the updated one soon.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] Test on disassemble
  2013-11-22 18:29   ` Tom Tromey
@ 2013-11-25  3:10     ` Yao Qi
  2013-11-27 21:33       ` Tom Tromey
  0 siblings, 1 reply; 13+ messages in thread
From: Yao Qi @ 2013-11-25  3:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 11/23/2013 02:21 AM, Tom Tromey wrote:
> Yao> +    global gdb_prompt
> Yao> +    set gdb_prompt "\[(\]top-gdb\[)\]"
> 
> It seems to me that this sort of change ought to be undone after the
> tests are complete.  Otherwise, it could affect subsequent tests.
> 
> To do that properly, you'll want to use "catch".  Or, if you want to
> wrap it up "macro style" see with_test_prefix.

A new proc with_gdb_prompt is added.  How about the patch below?

-- 
Yao (齐尧)

gdb/testsuite/

2013-11-25  Yao Qi  <yao@codesourcery.com>

	* lib/gdb.exp (with_gdb_prompt): New proc.
	* gdb.perf/disassemble.exp: New.
	* gdb.perf/disassemble.py: New.
---
 gdb/testsuite/gdb.perf/disassemble.exp |   57 ++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.perf/disassemble.py  |   35 +++++++++++++++++++
 gdb/testsuite/lib/gdb.exp              |   26 ++++++++++++++
 3 files changed, 118 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.perf/disassemble.exp
 create mode 100644 gdb/testsuite/gdb.perf/disassemble.py

diff --git a/gdb/testsuite/gdb.perf/disassemble.exp b/gdb/testsuite/gdb.perf/disassemble.exp
new file mode 100644
index 0000000..8f07a59
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/disassemble.exp
@@ -0,0 +1,57 @@
+# 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/>.
+
+# This test case is to test the speed of GDB when it is doing disassemble
+# some large functions in GDB.
+load_lib perftest.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+global GDB
+
+standard_testfile .c
+# Overwrite $binfile
+set binfile $GDB
+
+PerfTest::assemble {
+    # Don't have compilation step.
+    return 0
+} {
+    global srcdir subdir
+    global binfile
+
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+
+    # When GDB is debugging GDB, the prompt is changed to "(top-gdb) ".
+    # In order to avoid the confusion of pattern matching, set the
+    # gdb_prompt to '(top-gdb)' temporarily.
+    with_gdb_prompt "\\(top-gdb\\)" {
+	gdb_load ${binfile}
+    }
+
+    # The prompt of both parent GDB and child GDB is '(gdb)', but
+    # child GDB's prompt doesn't confuse pattern matching because but
+    # we only run to main function of child GDB, so child GDB's
+    # prompt can't be printed out.
+    if ![runto_main] {
+	return -1
+    }
+} {
+    gdb_test "python Disassemble\(\).run()"
+}
diff --git a/gdb/testsuite/gdb.perf/disassemble.py b/gdb/testsuite/gdb.perf/disassemble.py
new file mode 100644
index 0000000..fac1638
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/disassemble.py
@@ -0,0 +1,35 @@
+# 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/>.
+
+from perftest import perftest
+
+class Disassemble(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self):
+        super (Disassemble, self).__init__ ("disassemble")
+
+    def warm_up(self):
+        do_test_command = "disassemble ada_evaluate_subexp"
+        gdb.execute (do_test_command, False, True)
+
+    def _do_test(self, c):
+        for func in ["evaluate_subexp_standard", "handle_inferior_event", "c_parse_internal"]:
+            do_test_command = "disassemble %s" % func
+            for _ in range(c+1):
+                gdb.execute (do_test_command, False, True)
+
+    def execute_test(self):
+        for i in range(3):
+            self.measure.measure(lambda: self._do_test(i), i)
+
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index b8b21ab..2c1cf29 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1716,6 +1716,32 @@ proc with_test_prefix { prefix body } {
   }
 }
 
+# Run tests in BODY with GDB prompt and variable $gdb_prompt set to
+# PROMPT.  When BODY is finished, restore GDB prompt and variable
+# $gdb_prompt.
+# Returns the result of BODY.
+
+proc with_gdb_prompt { prompt body } {
+    global gdb_prompt
+
+    set saved $gdb_prompt
+
+    set gdb_prompt $prompt
+    gdb_test_no_output "set prompt $prompt " ""
+
+    set code [catch {uplevel 1 $body} result]
+
+    set gdb_prompt $saved
+    gdb_test_no_output "set prompt $saved " ""
+
+    if {$code == 1} {
+	global errorInfo errorCode
+	return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+    } else {
+	return -code $code $result
+    }
+}
+
 # Return 1 if _Complex types are supported, otherwise, return 0.
 
 gdb_caching_proc support_complex_tests {
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH 1/3] Test on disassemble
  2013-11-24  7:05     ` Yao Qi
@ 2013-11-25  9:17       ` Agovic, Sanimir
  0 siblings, 0 replies; 13+ messages in thread
From: Agovic, Sanimir @ 2013-11-25  9:17 UTC (permalink / raw)
  To: 'Yao Qi'; +Cc: gdb-patches

Thanks for the explanatory notes. See my remarks below.

 -Sanimir

> -----Original Message-----
> From: Yao Qi [mailto:yao@codesourcery.com]
> Sent: Sunday, November 24, 2013 06:02 AM
> To: Agovic, Sanimir
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH 1/3] Test on disassemble
> 
> On 11/20/2013 09:24 PM, Agovic, Sanimir wrote:
> > How about an option to measure performance without a running inferior
> > e.g. exec on top of the target stack? This may eliminate some overhead.
> >
> 
> On target exec, GDB will read data from local executable file, which
> should be quite fast and it won't bring any performance issues.
> 
> We need a running inferior, so that GDB will read data from target, with
> some overhead of communication between GDB and target.  We'd like to
> measure the performance like that, and alarm if GDB becomes slow.
> 
Maybe we should rename the test to TargetMemoryRead? If the idea is to
catch memory IO regressions the name reflects the intent better.

> > Does opcode/ provide some kind of null-op disassembler we can
> > use instead of a real ISA? A simple gdb source change or compiler
> > upgrade could make comparative runs quite hard.
> 
> I don't know what kind of simple gdb source change may affect the
> result.  If gdb source changes affect the result to some extent, such as
> 30%, such changes are what we want to monitor, right?
> 
Indeed. FYI: I had code refactoring's in mind which shuffle code around and thus
change the size of the targeted functions. Similar affects could be triggered by
compiler upgrades/flags changing inlining heuristics.

This patch looks good to me.

> The process of disassemble is I/O intensive, so probably compiler
> upgrade has minor effects on the result.  On the other hand, we should
> avoid changing factors other than GDB itself when measuring GDB performance.
> 
> >> >+
> >> >+from perftest import perftest
> >> >+from perftest import measure
> >> >+
> > I see no use of 'measure', is it still needed?
> >
> 
> No, I'll remove it from these three cases.
> 
> >> >+class Disassemble(perftest.TestCaseWithBasicMeasurements):
> >> >+    def __init__(self):
> >> >+        super (Disassemble, self).__init__ ("disassemble")
> >> >+
> >> >+    def warm_up(self):
> >> >+        do_test_command = "disassemble ada_evaluate_subexp"
> >> >+        gdb.execute (do_test_command, False, True)
> >> >+
> >> >+    def _do_test(self, c):
> >> >+        for func in ["evaluate_subexp_standard", "handle_inferior_event",
> >> >"c_parse_internal"]:
> >> >+            for i in range(c+1):
> >> >+                do_test_command = "disassemble %s" % func
> >> >
> > You may move this to the outer loop. Please use _ if you do not use the value "i".
> >
> 
> Thanks for the tip.  I'll post the updated one soon.
> 
> --
> Yao (齐尧)
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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] Test on disassemble
  2013-11-25  3:10     ` Yao Qi
@ 2013-11-27 21:33       ` Tom Tromey
  2013-11-28  6:34         ` Yao Qi
  0 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2013-11-27 21:33 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:

Yao> A new proc with_gdb_prompt is added.  How about the patch below?

Yao> 2013-11-25  Yao Qi  <yao@codesourcery.com>

Yao> 	* lib/gdb.exp (with_gdb_prompt): New proc.
Yao> 	* gdb.perf/disassemble.exp: New.
Yao> 	* gdb.perf/disassemble.py: New.

Looks good, thanks.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/3] Test on disassemble
  2013-11-27 21:33       ` Tom Tromey
@ 2013-11-28  6:34         ` Yao Qi
  0 siblings, 0 replies; 13+ messages in thread
From: Yao Qi @ 2013-11-28  6:34 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 11/28/2013 04:33 AM, Tom Tromey wrote:
> Yao> A new proc with_gdb_prompt is added.  How about the patch below?
>
> Yao> 2013-11-25  Yao Qi<yao@codesourcery.com>
>
> Yao> 	* lib/gdb.exp (with_gdb_prompt): New proc.
> Yao> 	* gdb.perf/disassemble.exp: New.
> Yao> 	* gdb.perf/disassemble.py: New.
>
> Looks good, thanks.

Patch is pushed.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-11-28  5:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-20  2:53 [PATCH 0/3] More perf test cases Yao Qi
2013-11-20  2:52 ` [PATCH 1/3] Test on disassemble Yao Qi
2013-11-20 15:50   ` Agovic, Sanimir
2013-11-24  7:05     ` Yao Qi
2013-11-25  9:17       ` Agovic, Sanimir
2013-11-22 18:29   ` Tom Tromey
2013-11-25  3:10     ` Yao Qi
2013-11-27 21:33       ` Tom Tromey
2013-11-28  6:34         ` Yao Qi
2013-11-20  2:53 ` [PATCH 2/3] Test on single step Yao Qi
2013-11-22 18:30   ` Tom Tromey
2013-11-20  2:59 ` [PATCH 3/3] Test on backtrace Yao Qi
2013-11-22 18:55   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).