diff mbox

[8/8] gen-perf-test: gmonster 1,2

Message ID 001a1136b44c95011d051b635eb4@google.com
State New
Headers show

Commit Message

Doug Evans July 21, 2015, 2:21 p.m. UTC
Hi.

This patch contains two test programs and a collection of
perf tests that I have found useful. Each program is
based on a real program. For perf-testing, gdb doesn't
need to know the details of the program, the program
just has to look/behave equivalently.
While gmonster1,2 don't look anything like their real
counterparts :-), they're sufficient to exercise the perf
issues I have seen (I have a few more things to
exercise a few more perf issues, but the patch set is
in a usable state now).
Each of the perf tests exercises a perf issue I have seen.

In order to not impose long build times in the default case,
each testcase has a parameter, MONSTER, that can be set to y or n.
The default is n. Setting it to y generates sufficient copies
of my real programs (though I still have more calibrating to do).

2015-07-20  Doug Evans  <dje@google.com>

	* gdb.perf/lib/perftest/utils.py: New file.
	* gdb.perf/gm-hello.cc: New file.
	* gdb.perf/gm-pervasive-typedef.cc: New file.
	* gdb.perf/gm-pervasive-typedef.h: New file.
	* gdb.perf/gm-std.cc: New file.
	* gdb.perf/gm-std.h: New file.
	* gdb.perf/gm-use-cerr.cc: New file.
	* gdb.perf/gm-utils.h: New file.
	* gdb.perf/gmonster-null-lookup.py: New file.
	* gdb.perf/gmonster-pervasive-typedef.py: New file.
	* gdb.perf/gmonster-print-cerr.py: New file.
	* gdb.perf/gmonster-ptype-string.py: New file.
	* gdb.perf/gmonster-runto-main.py: New file.
	* gdb.perf/gmonster-select-file.py: New file.
	* gdb.perf/gmonster1-null-lookup.exp: New file.
	* gdb.perf/gmonster1-pervasive-typedef.exp: New file.
	* gdb.perf/gmonster1-print-cerr.exp: New file.
	* gdb.perf/gmonster1-ptype-string.exp: New file.
	* gdb.perf/gmonster1-runto-main.exp: New file.
	* gdb.perf/gmonster1-select-file.exp: New file.
	* gdb.perf/gmonster1.cc: New file.
	* gdb.perf/gmonster1.exp: New file.
	* gdb.perf/gmonster2-null-lookup.exp: New file.
	* gdb.perf/gmonster2-pervasive-typedef.exp: New file.
	* gdb.perf/gmonster2-print-cerr.exp: New file.
	* gdb.perf/gmonster2-ptype-string.exp: New file.
	* gdb.perf/gmonster2-runto-main.exp: New file.
	* gdb.perf/gmonster2-select-file.exp: New file.
	* gdb.perf/gmonster2.cc: New file.
	* gdb.perf/gmonster2.exp: New file.
diff mbox

Patch

diff --git a/gdb/testsuite/gdb.perf/gm-hello.cc  
b/gdb/testsuite/gdb.perf/gm-hello.cc
new file mode 100644
index 0000000..80a7dbc
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-hello.cc
@@ -0,0 +1,25 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#include <string>
+#include "gm-utils.h"
+
+#ifdef SHLIB
+#define HELLO CONCAT2 (hello_, SHLIB)
+#else
+#define HELLO hello
+#endif
+
+std::string HELLO ("Hello.");
diff --git a/gdb/testsuite/gdb.perf/gm-pervasive-typedef.cc  
b/gdb/testsuite/gdb.perf/gm-pervasive-typedef.cc
new file mode 100644
index 0000000..e7712dc
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-pervasive-typedef.cc
@@ -0,0 +1,30 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#include "gm-pervasive-typedef.h"
+
+my_int use_of_my_int;
+
+void
+call_use_my_int_1 (my_int x)
+{
+  use_of_my_int = use_my_int (x);
+}
+
+void
+call_use_my_int ()
+{
+  call_use_my_int_1 (42);
+}
diff --git a/gdb/testsuite/gdb.perf/gm-pervasive-typedef.h  
b/gdb/testsuite/gdb.perf/gm-pervasive-typedef.h
new file mode 100644
index 0000000..6b65c27
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-pervasive-typedef.h
@@ -0,0 +1,30 @@ 
+/* Copyright (C) 2015 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 file is used to create the conditions for the perf regression
+   in pr 16253.  */
+
+#ifndef GM_PERVASIVE_TYPEDEF_H
+#define GM_PERVASIVE_TYPEDEF_H
+
+typedef int my_int;
+
+static my_int
+use_my_int (my_int x)
+{
+  return x + 1;
+}
+
+#endif /* GM_PERVASIVE_TYPEDEF_H */
diff --git a/gdb/testsuite/gdb.perf/gm-std.cc  
b/gdb/testsuite/gdb.perf/gm-std.cc
new file mode 100644
index 0000000..89ac500
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-std.cc
@@ -0,0 +1,36 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#include <iostream>
+#include "gm-std.h"
+
+namespace gm_std
+{
+
+ostream cerr;
+
+void
+init ()
+{
+  cerr.stream = &std::cerr;
+}
+
+template class basic_ostream<char>;
+
+template
+ostream&
+operator<< (ostream& out, const char* s);
+
+}
diff --git a/gdb/testsuite/gdb.perf/gm-std.h  
b/gdb/testsuite/gdb.perf/gm-std.h
new file mode 100644
index 0000000..8bda713
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-std.h
@@ -0,0 +1,57 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#ifndef GM_STD_H
+#define GM_STD_H
+
+#include <iostream>
+
+namespace gm_std
+{
+
+// Mock std::cerr, so we don't have to worry about the vagaries of the
+// system-provided one.  E.g., gcc pr 65669.
+// This contains just enough to exercise what we want to.
+template<typename T>
+  class basic_ostream
+{
+ public:
+  std::ostream *stream;
+};
+
+template<typename T>
+  basic_ostream<T>&
+operator<< (basic_ostream<T>& out, const char* s)
+{
+  (*out.stream) << s;
+  return out;
+}
+
+typedef basic_ostream<char> ostream;
+
+// Inhibit implicit instantiations for required instantiations,
+// which are defined via explicit instantiations elsewhere.
+extern template class basic_ostream<char>;
+extern template ostream& operator<< (ostream&, const char*);
+
+extern ostream cerr;
+
+// Call this from main so we don't have to do the same tricks that
+// libstcd++ does with ios init'n.
+extern void init ();
+
+}
+
+#endif /* GM_STD_H */
diff --git a/gdb/testsuite/gdb.perf/gm-use-cerr.cc  
b/gdb/testsuite/gdb.perf/gm-use-cerr.cc
new file mode 100644
index 0000000..5ef453b
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-use-cerr.cc
@@ -0,0 +1,29 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#include "gm-std.h"
+#include "gm-utils.h"
+
+#ifdef SHLIB
+#define WRITE_CERR XCONCAT2 (write_cerr_, SHLIB)
+#else
+#define WRITE_CERR write_cerr
+#endif
+
+void
+WRITE_CERR ()
+{
+  gm_std::cerr << "Yikes!\n";
+}
diff --git a/gdb/testsuite/gdb.perf/gm-utils.h  
b/gdb/testsuite/gdb.perf/gm-utils.h
new file mode 100644
index 0000000..f95ae06
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gm-utils.h
@@ -0,0 +1,25 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#ifndef GM_UTILS_H
+#define GM_UTILS_H
+
+/* Names borrowed from include/symcat.h.  */
+#define CONCAT2(a,b) a ## b
+#define XCONCAT2(a,b) CONCAT2 (a, b)
+#define STRINGX(s) #s
+#define XSTRING(s) STRINGX (s)
+
+#endif /* GM_UTILS_H */
diff --git a/gdb/testsuite/gdb.perf/gmonster-null-lookup.py  
b/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
new file mode 100644
index 0000000..dc18d89
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster-null-lookup.py
@@ -0,0 +1,46 @@ 
+# Copyright (C) 2015 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/>.
+
+# Test handling of lookup of a symbol that doesn't exist.
+# Efficient handling of this case is important, and not just for typos.
+# Sometimes the debug info for the needed object isn't present.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class NullLookup(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, name, run_names, binfile):
+        # We want to measure time in this test.
+        super(NullLookup, self).__init__(name)
+        self.run_names = run_names
+        self.binfile = binfile
+
+    def warm_up(self):
+        pass
+
+    def execute_test(self):
+        for run in self.run_names:
+            this_run_binfile = "%s-%s" % (self.binfile,
+                                          utils.convert_spaces(run))
+            utils.select_file(this_run_binfile)
+            utils.runto_main()
+            utils.safe_execute("mt expand-symtabs")
+            iteration = 5
+            while iteration > 0:
+                utils.safe_execute("mt flush-symbol-cache")
+                func = lambda: utils.safe_execute("p symbol_not_found")
+                self.measure.measure(func, run)
+                iteration -= 1
diff --git a/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py  
b/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
new file mode 100644
index 0000000..53eaf5e
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster-pervasive-typedef.py
@@ -0,0 +1,45 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure the speed of "ptype func" where a parameter of the function is a
+# typedef used pervasively.  This exercises the perf regression introduced  
by
+# the original patch to pr 16253.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class PervasiveTypedef(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, name, run_names, binfile):
+        # We want to measure time in this test.
+        super(PervasiveTypedef, self).__init__(name)
+        self.run_names = run_names
+        self.binfile = binfile
+
+    def warm_up(self):
+        pass
+
+    def func(self):
+        utils.select_file(self.this_run_binfile)
+        utils.safe_execute("ptype call_use_my_int_1")
+
+    def execute_test(self):
+        for run in self.run_names:
+            self.this_run_binfile = "%s-%s" % (self.binfile,
+                                               utils.convert_spaces(run))
+            iteration = 5
+            while iteration > 0:
+                self.measure.measure(self.func, run)
+                iteration -= 1
diff --git a/gdb/testsuite/gdb.perf/gmonster-print-cerr.py  
b/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
new file mode 100644
index 0000000..0a768ef
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster-print-cerr.py
@@ -0,0 +1,52 @@ 
+# Copyright (C) 2015 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/>.
+
+# Test printing of std::cerr.
+# libstdc++ is typically near the end of the list of shared libraries,
+# and thus searched last (or near last).
+# Plus llvm had a bug where its pubnames output that gold uses to generate
+# the index caused a massive perf regression (basically it emitted an entry
+# for every CU that used it, whereas we only want the CU with the
+# definition).
+#
+# Note: One difference between this test and gmonster-ptype-string.py
+# is that here we do not pre-expand the symtab: we don't want include
+# GDB's slowness in searching expanded symtabs first to color these  
results.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class PrintCerr(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, name, run_names, binfile):
+        super(PrintCerr, self).__init__(name)
+        self.run_names = run_names
+        self.binfile = binfile
+
+    def warm_up(self):
+        pass
+
+    def execute_test(self):
+        for run in self.run_names:
+            this_run_binfile = "%s-%s" % (self.binfile,
+                                          utils.convert_spaces(run))
+            utils.select_file(this_run_binfile)
+            utils.runto_main()
+            iteration = 5
+            while iteration > 0:
+                utils.safe_execute("mt flush-symbol-cache")
+                func = lambda: utils.safe_execute("print gm_std::cerr")
+                self.measure.measure(func, run)
+                iteration -= 1
diff --git a/gdb/testsuite/gdb.perf/gmonster-ptype-string.py  
b/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
new file mode 100644
index 0000000..c6c9ae4
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster-ptype-string.py
@@ -0,0 +1,48 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of ptype of a std::string object.
+# The difference between this test and gmonster-print-cerr.py is that
+# here we are working with fully expanded symtabs.  GDB searches
+# these before it searches the index (there is work-in-progress to fix  
this),
+# this test helps measure the issue.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class GmonsterPtypeString(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, name, run_names, binfile):
+        super(GmonsterPtypeString, self).__init__(name)
+        self.run_names = run_names
+        self.binfile = binfile
+
+    def warm_up(self):
+        pass
+
+    def execute_test(self):
+        for run in self.run_names:
+            this_run_binfile = "%s-%s" % (self.binfile,
+                                          utils.convert_spaces(run))
+            utils.select_file(this_run_binfile)
+            utils.runto_main()
+            utils.safe_execute("mt expand-symtabs")
+            iteration = 5
+            while iteration > 0:
+                utils.safe_execute("mt flush-symbol-cache")
+                func1 = lambda: utils.safe_execute("ptype hello")
+                func = lambda: utils.run_n_times(2, func1)
+                self.measure.measure(func, run)
+                iteration -= 1
diff --git a/gdb/testsuite/gdb.perf/gmonster-runto-main.py  
b/gdb/testsuite/gdb.perf/gmonster-runto-main.py
new file mode 100644
index 0000000..0895926
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster-runto-main.py
@@ -0,0 +1,40 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure performance of running to main.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class GmonsterRuntoMain(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, name, run_names, binfile):
+        super(GmonsterRuntoMain, self).__init__(name)
+        self.run_names = run_names
+        self.binfile = binfile
+
+    def warm_up(self):
+        pass
+
+    def execute_test(self):
+        for run in self.run_names:
+            this_run_binfile = "%s-%s" % (self.binfile,
+                                          utils.convert_spaces(run))
+            utils.select_file(this_run_binfile)
+            iteration = 5
+            while iteration > 0:
+                func = lambda: utils.runto_main()
+                self.measure.measure(func, run)
+                iteration -= 1
diff --git a/gdb/testsuite/gdb.perf/gmonster-select-file.py  
b/gdb/testsuite/gdb.perf/gmonster-select-file.py
new file mode 100644
index 0000000..4a8a96a
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster-select-file.py
@@ -0,0 +1,43 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure performance of selecting a file to debug.
+
+from perftest import perftest
+from perftest import measure
+from perftest import utils
+
+class GmonsterSelectFile(perftest.TestCaseWithBasicMeasurements):
+    def __init__(self, name, run_names, binfile):
+        super(GmonsterSelectFile, self).__init__(name)
+        self.run_names = run_names
+        self.binfile = binfile
+
+    def warm_up(self):
+        pass
+
+    def _doit(self, binfile):
+        utils.select_file(None)
+        utils.select_file(binfile)
+
+    def execute_test(self):
+        for run in self.run_names:
+            this_run_binfile = "%s-%s" % (self.binfile,
+                                          utils.convert_spaces(run))
+            iteration = 5
+            while iteration > 0:
+                func = lambda: self._doit(this_run_binfile)
+                self.measure.measure(func, run)
+                iteration -= 1
diff --git a/gdb/testsuite/gdb.perf/gmonster1-null-lookup.exp  
b/gdb/testsuite/gdb.perf/gmonster1-null-lookup.exp
new file mode 100644
index 0000000..1e09598
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1-null-lookup.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of lookup of a symbol that doesn't exist.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config  
gmonster-null-lookup.py NullLookup
diff --git a/gdb/testsuite/gdb.perf/gmonster1-pervasive-typedef.exp  
b/gdb/testsuite/gdb.perf/gmonster1-pervasive-typedef.exp
new file mode 100644
index 0000000..71f7d09
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1-pervasive-typedef.exp
@@ -0,0 +1,28 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure the speed of "ptype func" where a parameter of the function is a
+# typedef used pervasively.  This exercises the perf regression introduced  
by
+# the original patch to pr 16253.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config  
gmonster-pervasive-typedef.py PervasiveTypedef
diff --git a/gdb/testsuite/gdb.perf/gmonster1-print-cerr.exp  
b/gdb/testsuite/gdb.perf/gmonster1-print-cerr.exp
new file mode 100644
index 0000000..8725e70
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1-print-cerr.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of printing std::cerr.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config  
gmonster-print-cerr.py PrintCerr
diff --git a/gdb/testsuite/gdb.perf/gmonster1-ptype-string.exp  
b/gdb/testsuite/gdb.perf/gmonster1-ptype-string.exp
new file mode 100644
index 0000000..423ce85
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1-ptype-string.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of ptype on a simple class in a library that is searched  
late.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config  
gmonster-ptype-string.py GmonsterPtypeString
diff --git a/gdb/testsuite/gdb.perf/gmonster1-runto-main.exp  
b/gdb/testsuite/gdb.perf/gmonster1-runto-main.exp
new file mode 100644
index 0000000..9b39f64
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1-runto-main.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure performance of running to main.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config  
gmonster-runto-main.py GmonsterRuntoMain
diff --git a/gdb/testsuite/gdb.perf/gmonster1-select-file.exp  
b/gdb/testsuite/gdb.perf/gmonster1-select-file.exp
new file mode 100644
index 0000000..d97080d
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1-select-file.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure performance of selecting a file to debug.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster1.exp make_testcase_config  
gmonster-select-file.py GmonsterSelectFile
diff --git a/gdb/testsuite/gdb.perf/gmonster1.cc  
b/gdb/testsuite/gdb.perf/gmonster1.cc
new file mode 100644
index 0000000..4ae9837
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1.cc
@@ -0,0 +1,24 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#include "gm-std.h"
+
+int
+main ()
+{
+  gm_std::init ();
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.perf/gmonster1.exp  
b/gdb/testsuite/gdb.perf/gmonster1.exp
new file mode 100644
index 0000000..b3111d2
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster1.exp
@@ -0,0 +1,116 @@ 
+# Copyright (C) 2015 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/>.
+
+# Perftest description file for building the "gmonster1" benchmark.
+# Where does the name come from?  The benchmark is derived from one of the
+# monster programs at Google.
+#
+# Perftest descriptions are loaded thrice:
+# 1) To generate the build .exp files
+#    GDB_PERFTEST_MODE=gen-build-exps
+#    This step allows for parallel builds of the majority of pieces of the
+#    test binary and shlibs.
+# 2) To compile the "pieces" of the binary and shlibs.
+#    "Pieces" are the bulk of the machine-generated sources of the test.
+#    This step is driven by lib/build-piece.exp.
+#    GDB_PERFTEST_MODE=build-pieces
+# 3) To perform the final link of the binary and shlibs.
+#    GDB_PERFTEST_MODE=compile
+#
+# Example usage:
+# bash$ make -j5 build-perf RUNTESTFLAGS="gmonster1.exp gmonster2.exp"
+# bash$ make check-perf RUNTESTFLAGS="gdb.perf/gm*-*.exp GDB=/path/to/gdb"
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+if ![info exists MONSTER] {
+    set MONSTER "n"
+}
+
+proc make_testcase_config { } {
+    global MONSTER
+
+    set program_name "gmonster1"
+    array set testcase [GenPerfTest::init_testcase $program_name]
+
+    set testcase(language) c++
+
+    # *_{sources,headers} need to be embedded in an outer list
+    # because remember each element of the outer list is for each run, and
+    # here we want to use the same value for all runs.
+    set testcase(binary_extra_sources) { { gmonster1.cc gm-hello.cc  
gm-use-cerr.cc gm-pervasive-typedef.cc } }
+    set testcase(binary_extra_headers) { { <stdint.h> gm-utils.h gm-std.h  
gm-pervasive-typedef.h } }
+    set testcase(tail_shlib_sources) { { gm-std.cc } }
+    set testcase(tail_shlib_headers) { { gm-std.h } }
+
+    if { $MONSTER == "y" } {
+	set testcase(run_names) { 10-cus 100-cus 1000-cus 10000-cus }
+	set testcase(nr_compunits) { 10 100 1000 10000 }
+    } else {
+	set testcase(run_names) { 1-cu 10-cus 100-cus }
+	set testcase(nr_compunits) { 1 10 100 }
+    }
+    set testcase(nr_gen_shlibs) { 0 }
+
+    set testcase(nr_extern_globals) 10
+    set testcase(nr_static_globals) 10
+    set testcase(nr_extern_functions) 10
+    set testcase(nr_static_functions) 10
+
+    # class_specs needs to be embedded in an outer list because remember
+    # each element of the outer list is for each run, and here we want to  
use
+    # the same value for all runs.
+    set testcase(class_specs) { {
+	{
+	    count 1 name { class }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 class }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 anonymous aclass }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 ns1 class }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 anonymous ns1 aclass }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+    } }
+
+    return [array get testcase]
+}
+
+GenPerfTest::standard_compile_driver gmonster1.exp make_testcase_config
diff --git a/gdb/testsuite/gdb.perf/gmonster2-null-lookup.exp  
b/gdb/testsuite/gdb.perf/gmonster2-null-lookup.exp
new file mode 100644
index 0000000..c94dee0
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2-null-lookup.exp
@@ -0,0 +1,27 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of lookup of a symbol that doesn't exist
+# with lots of shared libraries.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config  
gmonster-null-lookup.py NullLookup
diff --git a/gdb/testsuite/gdb.perf/gmonster2-pervasive-typedef.exp  
b/gdb/testsuite/gdb.perf/gmonster2-pervasive-typedef.exp
new file mode 100644
index 0000000..ba7a92a
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2-pervasive-typedef.exp
@@ -0,0 +1,28 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure the speed of "ptype func" where a parameter of the function is a
+# typedef used pervasively.  This exercises the perf regression introduced  
by
+# the original patch to pr 16253.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config  
gmonster-pervasive-typedef.py PervasiveTypedef
diff --git a/gdb/testsuite/gdb.perf/gmonster2-print-cerr.exp  
b/gdb/testsuite/gdb.perf/gmonster2-print-cerr.exp
new file mode 100644
index 0000000..039641f
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2-print-cerr.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of printing std::cerr with lots of shared libraries.
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config  
gmonster-print-cerr.py PrintCerr
diff --git a/gdb/testsuite/gdb.perf/gmonster2-ptype-string.exp  
b/gdb/testsuite/gdb.perf/gmonster2-ptype-string.exp
new file mode 100644
index 0000000..37f2ed1
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2-ptype-string.exp
@@ -0,0 +1,27 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure speed of ptype on a simple class in a library that is searched  
late
+# with lots of shared libraries
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config  
gmonster-ptype-string.py GmonsterPtypeString
diff --git a/gdb/testsuite/gdb.perf/gmonster2-runto-main.exp  
b/gdb/testsuite/gdb.perf/gmonster2-runto-main.exp
new file mode 100644
index 0000000..12223f4
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2-runto-main.exp
@@ -0,0 +1,26 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure performance of running to main with lots of shared libraries
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config  
gmonster-runto-main.py GmonsterRuntoMain
diff --git a/gdb/testsuite/gdb.perf/gmonster2-select-file.exp  
b/gdb/testsuite/gdb.perf/gmonster2-select-file.exp
new file mode 100644
index 0000000..0a2864b
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2-select-file.exp
@@ -0,0 +1,27 @@ 
+# Copyright (C) 2015 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/>.
+
+# Measure performance of selecting a file to debug
+# with lots of shared libraries
+# Test parameters are the standard GenPerfTest parameters.
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+GenPerfTest::standard_run_driver gmonster2.exp make_testcase_config  
gmonster-select-file.py GmonsterSelectFile
diff --git a/gdb/testsuite/gdb.perf/gmonster2.cc  
b/gdb/testsuite/gdb.perf/gmonster2.cc
new file mode 100644
index 0000000..4ae9837
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2.cc
@@ -0,0 +1,24 @@ 
+/* Copyright (C) 2015 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/>.   
*/
+
+#include "gm-std.h"
+
+int
+main ()
+{
+  gm_std::init ();
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.perf/gmonster2.exp  
b/gdb/testsuite/gdb.perf/gmonster2.exp
new file mode 100644
index 0000000..15c6397
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/gmonster2.exp
@@ -0,0 +1,118 @@ 
+# Copyright (C) 2015 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/>.
+
+# Perftest description file for building the "gmonster2" benchmark.
+# Where does the name come from?  The benchmark is derived from one of the
+# monster programs at Google.
+#
+# Perftest descriptions are loaded thrice:
+# 1) To generate the build .exp files
+#    GDB_PERFTEST_MODE=gen-build-exps
+#    This step allows for parallel builds of the majority of pieces of the
+#    test binary and shlibs.
+# 2) To compile the "pieces" of the binary and shlibs.
+#    "Pieces" are the bulk of the machine-generated sources of the test.
+#    This step is driven by lib/build-piece.exp.
+#    GDB_PERFTEST_MODE=build-pieces
+# 3) To perform the final link of the binary and shlibs.
+#    GDB_PERFTEST_MODE=compile
+#
+# Example usage:
+# bash$ make -j5 build-perf RUNTESTFLAGS="gmonster1.exp gmonster2.exp"
+# bash$ make check-perf RUNTESTFLAGS="gdb.perf/gm*-*.exp GDB=/path/to/gdb"
+
+load_lib perftest.exp
+load_lib gen-perf-test.exp
+
+if [skip_perf_tests] {
+    return 0
+}
+
+if ![info exists MONSTER] {
+    set MONSTER "n"
+}
+
+proc make_testcase_config { } {
+    global MONSTER
+
+    set program_name "gmonster2"
+    array set testcase [GenPerfTest::init_testcase $program_name]
+
+    set testcase(language) c++
+
+    # *_{sources,headers} need to be embedded in an outer list
+    # because remember each element of the outer list is for each run, and
+    # here we want to use the same value for all runs.
+    set testcase(binary_extra_sources) { { gmonster2.cc gm-hello.cc  
gm-use-cerr.cc } }
+    set testcase(binary_extra_headers) { { gm-utils.h gm-std.h } }
+    set testcase(gen_shlib_extra_sources) { { gm-hello.cc gm-use-cerr.cc }  
}
+    set testcase(gen_shlib_extra_headers) { { gm-utils.h gm-std.h } }
+    set testcase(tail_shlib_sources) { { gm-std.cc } }
+    set testcase(tail_shlib_headers) { { gm-std.h } }
+
+    if { $MONSTER == "y" } {
+	set testcase(run_names) { 10-sos 100-sos 1000-sos }
+	set testcase(nr_gen_shlibs) { 10 100 1000 }
+    } else {
+	set testcase(run_names) { 1-so 10-sos 100-sos }
+	set testcase(nr_gen_shlibs) { 1 10 100 }
+    }
+    set testcase(nr_compunits) 10
+
+    set testcase(nr_extern_globals) 10
+    set testcase(nr_static_globals) 10
+    set testcase(nr_extern_functions) 10
+    set testcase(nr_static_functions) 10
+
+    # class_specs needs to be embedded in an outer list because remember
+    # each element of the outer list is for each run, and here we want to  
use
+    # the same value for all runs.
+    set testcase(class_specs) { {
+	{
+	    count 1 name { class }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 class }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 anonymous aclass }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 ns1 class }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+	{
+	    count 1 name { ns0 anonymous ns1 aclass }
+	    nr_members 10 nr_static_members 10
+	    nr_methods 10 nr_static_methods 10
+	    nr_inline_methods 10 nr_static_inline_methods 10
+	}
+    } }
+
+    return [array get testcase]
+}
+
+GenPerfTest::standard_compile_driver gmonster2.exp make_testcase_config
diff --git a/gdb/testsuite/gdb.perf/lib/perftest/utils.py  
b/gdb/testsuite/gdb.perf/lib/perftest/utils.py
new file mode 100644
index 0000000..e3b3443
--- /dev/null
+++ b/gdb/testsuite/gdb.perf/lib/perftest/utils.py
@@ -0,0 +1,68 @@ 
+# Copyright (C) 2015 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/>.
+
+import gdb
+
+def safe_execute(command):
+    """Execute command, ignoring any gdb errors."""
+    result = None
+    try:
+        result = gdb.execute(command, to_string=True)
+    except gdb.error:
+        pass
+    return result
+
+
+def convert_spaces(file_name):
+    """Return file_name with all spaces replaced with "-"."""
+    return file_name.replace(" ", "-")
+
+
+def select_file(file_name):
+    """Select a file for debugging.
+
+    N.B. This turns confirmation off.
+    """
+    safe_execute("set confirm off")
+    print ("Selecting file %s" % (file_name))
+    if file_name is None:
+        gdb.execute("file")
+    else:
+        gdb.execute("file %s" % (file_name))
+
+
+def runto(location):
+    """Run the program to location.
+
+    N.B. This turns confirmation off.
+    """
+    safe_execute("set confirm off")
+    gdb.execute("tbreak %s" % (location))
+    gdb.execute("run")
+
+
+def runto_main():
+    """Run the program to "main".
+
+    N.B. This turns confirmation off.
+    """
+    runto("main")
+
+
+def run_n_times(count, func):
+    """Execute func count times."""
+    while count > 0:
+        func()
+        count -= 1