diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-25 08:47:33 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-07-25 08:47:33 +0000 |
commit | bc1c8aef9de53e6c3aa24dd97ca1d2bf7f679796 (patch) | |
tree | 87d3c80e2398847cef0634f8a19a029b5b39d898 /libstdc++-v3/testsuite/performance | |
parent | 63864e1c15b724736e16990b93d8e31023ef5de5 (diff) | |
download | ppe42-gcc-bc1c8aef9de53e6c3aa24dd97ca1d2bf7f679796.tar.gz ppe42-gcc-bc1c8aef9de53e6c3aa24dd97ca1d2bf7f679796.zip |
2005-07-24 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/22515
* include/bits/basic_string.h: Declare the specialization
operator>>(basic_istream<char>&, basic_string<char>&).
* include/std/std_istream.h: Declate the specialization
operator>>(basic_istream<char>&, char*).
* include/std/std_streambuf.h (basic_streambuf): Add friend
declarations for the above.
* src/istream.cc: Define the above.
* testsuite/27_io/basic_istream/extractors_character/char/4.cc: New.
* testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc:
Likewise.
* testsuite/performance/27_io/ifstream_extract_chars.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102353 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/performance')
-rw-r--r-- | libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc b/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc new file mode 100644 index 00000000000..91a318b8934 --- /dev/null +++ b/libstdc++-v3/testsuite/performance/27_io/ifstream_extract_chars.cc @@ -0,0 +1,91 @@ +// Copyright (C) 2005 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 <cstdio> +#include <fstream> +#include <string> +#include <testsuite_performance.h> + +// libstdc++/22515 +int main() +{ + using namespace std; + using namespace __gnu_test; + + time_counter time; + resource_counter resource; + + const char filename[] = "tmp_perf_chars.txt"; + const unsigned lines = 200000; + const unsigned line_length = 200; + + char* line = new char[line_length + 2]; + + // Construct data. + { + memset(line, 'x', line_length); + line[line_length] = '\n'; + line[line_length + 1] = '\0'; + + ofstream out(filename); + for (unsigned i = 0; i < lines; ++i) + out << line; + } + + // operator>>(basic_istream<char>& __in, basic_string<char>& __str) + { + start_counters(time, resource); + for (int iter = 0; iter < 25; ++iter) + { + ifstream file(filename); + string string_line; + + while (file >> string_line); + } + stop_counters(time, resource); + report_performance(__FILE__, "string&", time, resource); + clear_counters(time, resource); + } + + // operator>>(basic_istream<char>& __in, char* __s) + { + start_counters(time, resource); + for (int iter = 0; iter < 25; ++iter) + { + ifstream file(filename); + + while (file >> line); + } + stop_counters(time, resource); + report_performance(__FILE__, "char*", time, resource); + clear_counters(time, resource); + } + + delete[] line; + unlink(filename); + return 0; +} |