Commit ca5e1be8 by Benjamin Kosnik Committed by Benjamin Kosnik

README: Move to...


2003-05-20  Benjamin Kosnik  <bkoz@redhat.com>

	* testsuite/README: Move to...
	* docs/html/test.html: ...here. Add documentation.
	* docs/html/install.html: Move testing bits out..
	* docs/html/documentation.html: Add separate testing link.
        * testsuite/performance: Add.
        * testsuite/performance/allocator.cc: New.
        * testsuite/performance/complex_norm.cc: New.
        * testsuite/performance/cout_insert_int.cc: New.
        * testsuite/performance/fstream_seek_write.cc: New.
        * testsuite/performance/ifstream_getline.cc: New.
        * testsuite/performance/map_create_fill.cc: New.
        * testsuite/performance/ofstream_insert_float.cc: New.
        * testsuite/performance/ofstream_insert_int.cc: New.
        * testsuite/performance/string_append.cc: New.
	* testsuite/lib/libstdc++-v3-dg.exp (v3-compute-tests): Filter
	performance tests.

From-SVN: r67040
parent f737a52d
2003-05-20 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/README: Move to...
* docs/html/test.html: ...here. Add documentation.
* docs/html/install.html: Move testing bits out..
* docs/html/documentation.html: Add separate testing link.
* testsuite/performance: Add.
* testsuite/performance/allocator.cc: New.
* testsuite/performance/complex_norm.cc: New.
* testsuite/performance/cout_insert_int.cc: New.
* testsuite/performance/fstream_seek_write.cc: New.
* testsuite/performance/ifstream_getline.cc: New.
* testsuite/performance/map_create_fill.cc: New.
* testsuite/performance/ofstream_insert_float.cc: New.
* testsuite/performance/ofstream_insert_int.cc: New.
* testsuite/performance/string_append.cc: New.
* testsuite/lib/libstdc++-v3-dg.exp (v3-compute-tests): Filter
performance tests.
2003-05-20 Gabriel Dos Reis <gdr@integrable-solutions.net> 2003-05-20 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR libstdc++/10689 PR libstdc++/10689
......
...@@ -45,11 +45,12 @@ ...@@ -45,11 +45,12 @@
<hr /> <hr />
<br /> <br />
<h2><a name="2">Configuring, Building, Installing</a></h2> <h2><a name="2">Configuring, Building, Testing, Installing</a></h2>
<ul> <ul>
<li><a href="configopts.html">Configure options</a></li> <li><a href="configopts.html">Configure options</a></li>
<li><a href="install.html">Getting started: configure, build, install</a> <li><a href="install.html">Getting started: configure, build, install</a>
</li> </li>
<li><a href="test.html">Testing details</a>
<li><a href="debug.html">Debugging schemes and strategies</a> <li><a href="debug.html">Debugging schemes and strategies</a>
</li> </li>
</ul> </ul>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
</head> </head>
<body> <body>
<h1 class="centered"><a name="top">libstdc++-v3 INSTALL</a></h1> <h1 class="centered"><a name="top">Getting started: configure, build, install</a></h1>
<p class="fineprint"><em> <p class="fineprint"><em>
The latest version of this document is always available at The latest version of this document is always available at
...@@ -312,36 +312,6 @@ se_NO.UTF-8 UTF-8 ...@@ -312,36 +312,6 @@ se_NO.UTF-8 UTF-8
the headers and library files will be moved under the headers and library files will be moved under
<code>lib/gcc-lib/</code> instead. <code>lib/gcc-lib/</code> instead.
</p> </p>
<p>You can check the status of the build without installing it using</p>
<pre>
make check</pre>
<p>or you can check the status of the installed library using</p>
<pre>
make check-install</pre>
<p>in the <em>libbuilddir</em> directory.
These commands will create a 'testsuite' directory underneath
<em>libbuilddir</em> containing the results of the tests. We are
interested in any strange failures of the testsuite; please see
<a href="faq/index.html#2_4">FAQ 2.4</a> for which files to examine.
</p>
<p> In addition, there are some testing options that are mostly of
interest to library maintainers and system integrators. As such,
these tests may not work on all cpu and host combinations. These
options include, but are not necessarily limited to, the following:
</p>
<p>The library ABI can be tested using</p>
<pre>
make check-abi</pre>
<p>The library can also be tested using a bash script, instead of
the default dejagnu test harness</p>
<pre>
make check-script</pre>
<p>or</p>
<pre>
make check-script-install</pre>
<hr /> <hr />
<h2><a name="usage">Using the library</a></h2> <h2><a name="usage">Using the library</a></h2>
......
We're in the process of converting the existing testsuite machinery to
use the new style DejaGnu framework. Eventually, we'll abandon
../mkcheck.in in favor of this new testsuite framework.
// 1: Thoughts on naming test cases, and structuring them.
The testsuite directory has been divided into 11 directories, directly
correlated to the relevant chapters in the standard. For example, the
directory testsuite/21_strings contains tests related to "Chapter 21,
Strings library" in the C++ standard.
So, the first step in making a new test case is to choose the correct
directory. The second item is seeing if a test file exists that tests
the item in question. Generally, within chapters test files are named
after the section headings in ISO 14882, the C++ standard. For instance,
21.3.7.9 Inserters and Extractors
Has a related test case:
21_strings/inserters_extractors.cc
Not so hard. Some time, the words "ctor" and "dtor" are used instead
of "construct", "constructor", "cons", "destructor", etc. Other than
that, the naming seems mostly consistent. If the file exists, add a
test to it. If it does not, then create a new file. All files are
copyright the FSF, and GPL'd: this is very important.
In addition, some of the locale and io code tests different
instantiating types: thus, 'char' or 'wchar_t' is appended to the name
as constructed above.
Also, some test files are negative tests. That is, they are supposed
to fail (usually this involves making sure some kind of construct gets
an error when it's compiled.) These test files have 'neg' appended to
the name as constructed above.
Inside a test file, the plan is to test the relevant parts of the
standard, and then add specific regressions as additional test
functions, ie test04() can represent a specific regression noted in
GNATS. Once test files get unwieldy or too big, then they should be
broken up into multiple sub-categories, hopefully intelligently named
after the relevant (and more specific) part of the standard.
// 2: How to write a test case, from a dejagnu perspective
As per the dejagnu instructions, always return 0 from main to indicate
success.
Basically, a test case contains dg-keywords (see dg.exp) indicating
what to do and what kinds of behaviour are to be expected. New
testcases should be written with the new style DejaGnu framework in
mind.
To ease transition, here is the list of dg-keyword documentation
lifted from dg.exp -- eventually we should improve DejaGnu
documentation, but getting checkin account currently demands Pyrrhic
effort.
# The currently supported options are:
#
# dg-prms-id N
# set prms_id to N
#
# dg-options "options ..." [{ target selector }]
# specify special options to pass to the tool (eg: compiler)
#
# dg-do do-what-keyword [{ target/xfail selector }]
# `do-what-keyword' is tool specific and is passed unchanged to
# ${tool}-dg-test. An example is gcc where `keyword' can be any of:
# preprocess|compile|assemble|link|run
# and will do one of: produce a .i, produce a .s, produce a .o,
# produce an a.out, or produce an a.out and run it (the default is
# compile).
#
# dg-error regexp comment [{ target/xfail selector } [{.|0|linenum}]]
# indicate an error message <regexp> is expected on this line
# (the test fails if it doesn't occur)
# Linenum=0 for general tool messages (eg: -V arg missing).
# "." means the current line.
#
# dg-warning regexp comment [{ target/xfail selector } [{.|0|linenum}]]
# indicate a warning message <regexp> is expected on this line
# (the test fails if it doesn't occur)
#
# dg-bogus regexp comment [{ target/xfail selector } [{.|0|linenum}]]
# indicate a bogus error message <regexp> use to occur here
# (the test fails if it does occur)
#
# dg-build regexp comment [{ target/xfail selector }]
# indicate the build use to fail for some reason
# (errors covered here include bad assembler generated, tool crashes,
# and link failures)
# (the test fails if it does occur)
#
# dg-excess-errors comment [{ target/xfail selector }]
# indicate excess errors are expected (any line)
# (this should only be used sparingly and temporarily)
#
# dg-output regexp [{ target selector }]
# indicate the expected output of the program is <regexp>
# (there may be multiple occurrences of this, they are concatenated)
#
# dg-final { tcl code }
# add some tcl code to be run at the end
# (there may be multiple occurrences of this, they are concatenated)
# (unbalanced braces must be \-escaped)
#
# "{ target selector }" is a list of expressions that determine whether the
# test succeeds or fails for a particular target, or in some cases whether the
# option applies for a particular target. If the case of `dg-do' it specifies
# whether the testcase is even attempted on the specified target.
#
# The target selector is always optional. The format is one of:
#
# { xfail *-*-* ... } - the test is expected to fail for the given targets
# { target *-*-* ... } - the option only applies to the given targets
#
# At least one target must be specified, use *-*-* for "all targets".
# At present it is not possible to specify both `xfail' and `target'.
# "native" may be used in place of "*-*-*".
Example 1: Testing compilation only
(to just have a testcase do compile testing, without linking and executing)
// { dg-do compile }
Example 2: Testing for expected warings on line 36
// { dg-warning "string literals" "" { xfail *-*-* } 36
Example 3: Testing for compilation errors on line 41
// { dg-do compile }
// { dg-error "no match for" "" { xfail *-*-* } 41 }
More examples can be found in the libstdc++-v3/testsuite/*/*.cc files.
// 3: Test harness notes, invocation, and debugging.
Configuring the dejagnu harness to work with libstdc++-v3 in a cross
compilation environment has been maddening. However, it does work now,
and on a variety of platforms. Including solaris, linux, and cygwin.
To debug the test harness during runs, try invoking with
make check-target-libstdc++-v3 RUNTESTFLAGS="-v"
or
make check-target-libstdc++-v3 RUNTESTFLAGS="-v -v"
There are two ways to run on a simulator: set up DEJAGNU to point to a
specially crafted site.exp, or pass down --target_board flags.
Example flags to pass down for various embedded builds are as follows:
--target=powerpc-eabism (libgloss/sim)
make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=powerpc-sim"
--target=calmrisc32 (libgloss/sid)
make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=calmrisc32-sid"
--target=xscale-elf (newlib/sim)
make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim"
// 4: Future plans, to be done
Shared runs need to be implemented, for targets that support shared libraries.
Diffing of expected output to standard streams needs to be finished off.
The V3 testing framework supports, or will eventually support,
additional keywords for the purpose of easing the job of writing
testcases. All V3-keywords are of the form @xxx@. Currently plans
for supported keywords include:
@require@ <files>
The existence of <files> is essential for the test to complete
successfully. For example, a testcase foo.C using bar.baz as
input file could say
// @require@ bar.baz
The special variable % stands for the rootname, e.g. the
file-name without its `.C' extension. Example of use (taken
verbatim from 27_io/filebuf.cc)
// @require@ %-*.tst %-*.txt
@diff@ <first-list> <second-list>
After the testcase compiles and ran successfully, diff
<first-list> against <second-list>, these lists should have the
same length. The test fails if diff returns non-zero a pair of
files.
Current testing problems with cygwin-hosted tools:
There are two known problems which I have not addressed. The first is
that when testing cygwin hosted tools from the unix build dir, it does
the wrong thing building the wrapper program (testglue.c) because host
and target are the same in site.exp (host and target are the same from
the perspective of the target libraries)
Problem number two is a little more annoying. In order for me to make
v3 testing work on Windows, I had to tell dejagnu to copy over the
debug_assert.h file to the remote host and then set the includes to
-I./. This is how all the other tests like this are done so I didn't
think much of it. However, this had some unfortunate results due to
gcc having a testcase called "limits" and C++ having an include file
called "limits". The gcc "limits" binary was in the temporary dir
when the v3 tests were being built. As a result, the gcc "limits"
binary was being #included rather than the intended one. The only way
to fix this is to go through the testsuites and make sure binaries are
deleted on the remote host when testing is done with them. That is a
lot more work than I want to do so I worked around it by cleaning out
D:\kermit on compsognathus and rerunning tests.
...@@ -233,6 +233,7 @@ proc v3-compute-tests { } { ...@@ -233,6 +233,7 @@ proc v3-compute-tests { } {
set tests_file "${outdir}/testsuite_files" set tests_file "${outdir}/testsuite_files"
set tests_file_inter "${outdir}/testsuite_files_interactive" set tests_file_inter "${outdir}/testsuite_files_interactive"
set tests_file_perf "${outdir}/testsuite_files_performance"
set sfiles "" set sfiles ""
# If there is a testsuite_file, use it. # If there is a testsuite_file, use it.
...@@ -281,6 +282,21 @@ proc v3-compute-tests { } { ...@@ -281,6 +282,21 @@ proc v3-compute-tests { } {
} }
set sfiles ${restwo} set sfiles ${restwo}
# Filter performance analysis tests.
# Use special rules to run these tests.
set resthree {}
set sfiles_perf {}
foreach i $sfiles {
if [regexp "performance" $i] {
verbose "element performance list is $i"
lappend sfiles_perf $i
} else {
verbose "element non-performancet list is $i"
lappend resthree $i
}
}
set sfiles ${resthree}
# Write out testsuite_files. # Write out testsuite_files.
set f [open $tests_file "w"] set f [open $tests_file "w"]
foreach t $sfiles { foreach t $sfiles {
...@@ -294,6 +310,13 @@ proc v3-compute-tests { } { ...@@ -294,6 +310,13 @@ proc v3-compute-tests { } {
puts $f $t puts $f $t
} }
close $f close $f
# Write out testsuite_files_performance.
set f [open $tests_file_perf "w"]
foreach t $sfiles_perf {
puts $f $t
}
close $f
} }
proc v3-list-tests { filename } { proc v3-list-tests { filename } {
......
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <list>
// Primarily a test of the default allocator.
// http://gcc.gnu.org/ml/libstdc++/2001-05/msg00105.html
int main ()
{
std::list<int> List;
for (int i = 0; i < 10000000; ++i )
List.push_back( int() );
return 0;
}
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <complex>
// based on libstdc++/5730, use --fast-math
int main()
{
typedef std::complex<double> complex_type;
complex_type u[2048];
for (int i = 0; i < 2048; ++i)
u[i] = 1.0;
for (int i = 0; i < 2000; ++i)
{
complex_type * p = u;
for (int j = 0; j < 2048; ++j)
{
#if 1
double u2 = norm(*p);
#else
// Shouldn't be slower than the above.
double ur = real(*p);
double ui = imag(*p);
double u2 = ur * ur + ui * ui;
#endif
double t = u2 * 0.1;
*p *= complex_type(cos(t), sin(t));
++p;
}
}
return 0;
}
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <iostream>
// libstdc++/7076
int main()
{
for (int i = 0; i < 150000; i++)
std::cout << i << '\n';
return 0;
}
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <fstream>
// libstdc++/10672
int main()
{
using namespace std;
fstream s("tmp_perf_seek", ios::binary | ios::in | ios::out | ios::trunc);
if (s.good())
{
for (int i = 0; i < 300000; i++)
{
s.seekp(0);
s.write((char *) & i, sizeof(int));
s.seekp(sizeof(int));
s.write((char *) & i, sizeof(int));
}
}
return 0;
}
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <fstream>
// libstdc++/5001 (100,000 line input file)
int main ()
{
using namespace std;
const char* name = "/usr/share/dict/linux.words";
ifstream in(name);
char buffer[BUFSIZ];
while(!in.eof())
{
in.getline(buffer, BUFSIZ);
}
}
// 2003-03-01 gp dot bolton at computer dot org
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
#include <map>
#include <testsuite_hooks.h>
static bool test = true;
static void create_and_fill(const unsigned int n)
{
typedef std::map<int, int> Map;
Map m;
for (unsigned int i = 0; i < n; ++i)
m[i] = i;
VERIFY ( m.size() == n );
}
void test01()
{
const unsigned n = 10000000;
for (unsigned int i = 0; i < n; ++i)
create_and_fill( 0 );
}
// http://gcc.gnu.org/ml/libstdc++/2003-03/msg00000.html
int main()
{
test01();
return 0;
}
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <fstream>
// based on libstdc++/8761 poor fstream performance (converted to float)
int main()
{
std::ofstream out("tmp_perf_float.txt");
for (int i = 0; i < 10000000; ++i)
{
float f = static_cast<float>(i);
out << f << "\n";
}
return 0;
};
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <fstream>
// libstdc++/8761 poor fstream performance
int main()
{
std::ofstream out("tmp_perf_int.txt");
for (int i = 0; i < 10000000; ++i)
out << i << "\n";
return 0;
};
// Copyright (C) 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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 2, or (at your option)
// any later version.
// This library 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 library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#include <ctime>
#include <iostream>
#include <string>
using namespace std;
void
test_append_char(int how_much)
{
string buf; // no preallocation
for (int i = 0; i < how_much; ++i)
buf.append(static_cast<string::size_type>(1) , 'x');
}
void
test_append_string(int how_much)
{
string s(static_cast<string::size_type>(1) , 'x');
string buf; // no preallocation
for (int i = 0; i < how_much; ++i)
buf.append(s);
}
void
run_benchmark1(int how_much)
{
clock_t t0 = clock();
test_append_char(how_much);
clock_t t1 = clock();
cout << "Execution time of " << how_much
<< " string::append(char) calls: "
<< (static_cast<float>(t1 - t0)/CLOCKS_PER_SEC) << " sec."<< endl;
}
void
run_benchmark2(int how_much)
{
clock_t t0 = clock();
test_append_string(how_much);
clock_t t1 = clock();
cout << "Execution time of " << how_much
<< " string::append(const string&) calls: "
<< (static_cast<float>(t1 - t0)/CLOCKS_PER_SEC) << " sec." << endl;
}
// libstdc++/5380
// libstdc++/4960
int main()
{
run_benchmark1(10000);
run_benchmark2(10000);
run_benchmark1(100000);
run_benchmark2(100000);
run_benchmark1(1000000);
run_benchmark2(1000000);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment