2008-05-05 Benjamin Kosnik * testsuite/util/testsuite_visualization.h: Move contents into... * testsuite/util/testsuite_performance.h: ...here. * testsuite/util/testsuite_common_types.h: Move performance-related test infrastructure into testsuite_performance. * testsuite/performance/25_algorithms/search_n.cc: Fix includes. * testsuite/performance/23_containers/find/map.cc: Same. * testsuite/performance/23_containers/create/map.cc: Same. * testsuite/performance/23_containers/insert_erase/associative.cc: Same. * testsuite/performance/23_containers/insert/sequence.cc: Same. * testsuite/performance/23_containers/insert/associative.cc: Same. * testsuite/performance/23_containers/create_from_sorted/set.cc: Same. * testsuite/performance/23_containers/index/map.cc: Same. * testsuite/performance/23_containers/insert_from_sorted/set.cc: Same. * testsuite/performance/23_containers/create_sort/list.cc: Same. * testsuite/performance/23_containers/sort_search/list.cc: Same. * testsuite/performance/23_containers/producer_consumer/sequence.cc: Same. * testsuite/performance/23_containers/producer_consumer/associative.cc: Same. * testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust line numbers. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. Index: testsuite/performance/25_algorithms/search_n.cc =================================================================== --- testsuite/performance/25_algorithms/search_n.cc (revision 134947) +++ testsuite/performance/25_algorithms/search_n.cc (working copy) @@ -53,7 +53,7 @@ array[i] = (match != 0) ? 1 : 0; if(--match < 0) match = rand() % (match_length - 1); } - test_container fcon(array, array + length); + __gnu_test::test_container fcon(array, array + length); start_counters(time, resource); for(int i = 0; i < 100; i++) search_n(fcon.begin(), fcon.end(), 10, 1); @@ -61,7 +61,7 @@ report_performance(__FILE__, "forward iterator", time, resource); clear_counters(time, resource); - test_container rcon(array, array + length); + __gnu_test::test_container rcon(array, array + length); start_counters(time, resource); for(int i = 0; i < 100; i++) search_n(rcon.begin(), rcon.end(), 10, 1); Index: testsuite/performance/23_containers/find/map.cc =================================================================== --- testsuite/performance/23_containers/find/map.cc (revision 134947) +++ testsuite/performance/23_containers/find/map.cc (working copy) @@ -27,7 +27,7 @@ // 2004-03-11 Dhruv Matani -#include +#include template void Index: testsuite/performance/23_containers/create/map.cc =================================================================== --- testsuite/performance/23_containers/create/map.cc (revision 134947) +++ testsuite/performance/23_containers/create/map.cc (working copy) @@ -27,7 +27,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/insert_erase/associative.cc =================================================================== --- testsuite/performance/23_containers/insert_erase/associative.cc (revision 134947) +++ testsuite/performance/23_containers/insert_erase/associative.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/insert/sequence.cc =================================================================== --- testsuite/performance/23_containers/insert/sequence.cc (revision 134947) +++ testsuite/performance/23_containers/insert/sequence.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/insert/associative.cc =================================================================== --- testsuite/performance/23_containers/insert/associative.cc (revision 134947) +++ testsuite/performance/23_containers/insert/associative.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/create_from_sorted/set.cc =================================================================== --- testsuite/performance/23_containers/create_from_sorted/set.cc (revision 134947) +++ testsuite/performance/23_containers/create_from_sorted/set.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/index/map.cc =================================================================== --- testsuite/performance/23_containers/index/map.cc (revision 134947) +++ testsuite/performance/23_containers/index/map.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include // libstdc++/13823 recast for this testing framework template Index: testsuite/performance/23_containers/insert_from_sorted/set.cc =================================================================== --- testsuite/performance/23_containers/insert_from_sorted/set.cc (revision 134947) +++ testsuite/performance/23_containers/insert_from_sorted/set.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/create_sort/list.cc =================================================================== --- testsuite/performance/23_containers/create_sort/list.cc (revision 134947) +++ testsuite/performance/23_containers/create_sort/list.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/sort_search/list.cc =================================================================== --- testsuite/performance/23_containers/sort_search/list.cc (revision 134947) +++ testsuite/performance/23_containers/sort_search/list.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include template void Index: testsuite/performance/23_containers/producer_consumer/sequence.cc =================================================================== --- testsuite/performance/23_containers/producer_consumer/sequence.cc (revision 134947) +++ testsuite/performance/23_containers/producer_consumer/sequence.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include typedef int test_type; Index: testsuite/performance/23_containers/producer_consumer/associative.cc =================================================================== --- testsuite/performance/23_containers/producer_consumer/associative.cc (revision 134947) +++ testsuite/performance/23_containers/producer_consumer/associative.cc (working copy) @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include +#include typedef int test_type; Index: testsuite/29_atomics/atomic/cons/assign_neg.cc =================================================================== --- testsuite/29_atomics/atomic/cons/assign_neg.cc (revision 134947) +++ testsuite/29_atomics/atomic/cons/assign_neg.cc (working copy) @@ -38,7 +38,7 @@ return 0; } -// { dg-error "within this context" "" { target *-*-* } 310 } +// { dg-error "within this context" "" { target *-*-* } 309 } // { dg-error "is private" "" { target *-*-* } 1750 } // { dg-error "is private" "" { target *-*-* } 1782 } // { dg-error "is private" "" { target *-*-* } 1799 } Index: testsuite/29_atomics/atomic/cons/copy_neg.cc =================================================================== --- testsuite/29_atomics/atomic/cons/copy_neg.cc (revision 134947) +++ testsuite/29_atomics/atomic/cons/copy_neg.cc (working copy) @@ -38,7 +38,7 @@ return 0; } -// { dg-error "within this context" "" { target *-*-* } 333 } +// { dg-error "within this context" "" { target *-*-* } 332 } // { dg-error "is private" "" { target *-*-* } 1749 } // { dg-error "is private" "" { target *-*-* } 1781 } // { dg-error "is private" "" { target *-*-* } 1798 } Index: testsuite/util/testsuite_visualization.h =================================================================== --- testsuite/util/testsuite_visualization.h (revision 134947) +++ testsuite/util/testsuite_visualization.h (working copy) @@ -1,150 +0,0 @@ -// 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -// 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 -#include -#include -#include -#include -#include - -// Ah, we wish it wasn't so... -bool first_container = false; -extern const char* filename; - -typedef std::string::size_type (*callback_type) (std::string&); - -template - void - write_viz_container(callback_type find_container, const char* filename) - { - typedef std::string string; - - // Create title. - { - const char ws(' '); - std::ostringstream title; - - std::string titlename(filename); - std::string::size_type n = titlename.find('.'); - if (n != string::npos) - titlename = std::string(titlename.begin(), titlename.begin() + n); - - title << titlename; - title << ws; - title << Iter; - title << ws; -#if 0 - title << "thread<"; - std::boolalpha(title); - title << Thread; - title << '>'; -#endif - - titlename += ".title"; - std::ofstream titlefile(titlename.c_str()); - if (!titlefile.good()) - throw std::runtime_error("write_viz_data cannot open titlename"); - titlefile << title.str() << std::endl; - } - - // Create compressed type name. - Container obj; - int status; - std::string type(abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status)); - - // Extract fully-qualified typename. - // Assumes "set" or "map" are uniquely determinate. - string::iterator beg = type.begin(); - string::iterator end; - string::size_type n = (*find_container)(type); - - // Find start of fully-qualified name. - // Assume map, find end. - string::size_type nend = type.find('<', n); - if (nend != string::npos) - end = type.begin() + nend; - - string compressed_type; - compressed_type += '"'; - compressed_type += string(beg, end); - compressed_type += '<'; -#if 0 - typename Container::key_type v; - compressed_type += typeid(v).name(); -#else - compressed_type += "int"; -#endif - compressed_type += ", A>"; - - // XXX - if (Thread == true) - compressed_type += " thread"; - compressed_type += '"'; - - std::ofstream file(filename, std::ios_base::app); - if (!file.good()) - throw std::runtime_error("write_viz_data cannot open filename"); - - file << compressed_type; - first_container = false; - } - - -void -write_viz_data(__gnu_test::time_counter& time, const char* filename) -{ - std::ofstream file(filename, std::ios_base::app); - if (!file.good()) - throw std::runtime_error("write_viz_data cannot open filename"); - - // Print out score in appropriate column. - const char tab('\t'); - int score = time.real_time(); - file << tab << score; -} - -void -write_viz_endl(const char* filename) -{ - std::ofstream file(filename, std::ios_base::app); - if (!file.good()) - throw std::runtime_error("write_viz_endl cannot open filename"); - file << std::endl; -} - - -#if 0 -// cons -write_viz_container(&sequence_find_container, - filename); -#endif - -#if 0 -// dtor -write_viz_endl(filename) -#endif Index: testsuite/util/testsuite_performance.h =================================================================== --- testsuite/util/testsuite_performance.h (revision 134947) +++ testsuite/util/testsuite_performance.h (working copy) @@ -1,7 +1,7 @@ // -*- C++ -*- // Testing performance utilities for the C++ library testsuite. // -// Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. +// Copyright (C) 2003, 2004, 2005, 2007, 2008 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 @@ -38,6 +38,11 @@ #include #include #include +#include +#include +#include +#include +#include #ifdef __linux__ #include @@ -260,5 +265,229 @@ } } // namespace __gnu_test + +// Ah, we wish it wasn't so... +bool first_container = false; +extern const char* filename; + +typedef std::string::size_type (*callback_type) (std::string&); + +template + void + write_viz_container(callback_type find_container, const char* filename) + { + typedef std::string string; + + // Create title. + { + const char ws(' '); + std::ostringstream title; + + std::string titlename(filename); + std::string::size_type n = titlename.find('.'); + if (n != string::npos) + titlename = std::string(titlename.begin(), titlename.begin() + n); + + title << titlename; + title << ws; + title << Iter; + title << ws; +#if 0 + title << "thread<"; + std::boolalpha(title); + title << Thread; + title << '>'; +#endif + + titlename += ".title"; + std::ofstream titlefile(titlename.c_str()); + if (!titlefile.good()) + throw std::runtime_error("write_viz_data cannot open titlename"); + titlefile << title.str() << std::endl; + } + + // Create compressed type name. + Container obj; + int status; + std::string type(abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status)); + + // Extract fully-qualified typename. + // Assumes "set" or "map" are uniquely determinate. + string::iterator beg = type.begin(); + string::iterator end; + string::size_type n = (*find_container)(type); + + // Find start of fully-qualified name. + // Assume map, find end. + string::size_type nend = type.find('<', n); + if (nend != string::npos) + end = type.begin() + nend; + + string compressed_type; + compressed_type += '"'; + compressed_type += string(beg, end); + compressed_type += '<'; +#if 0 + typename Container::key_type v; + compressed_type += typeid(v).name(); +#else + compressed_type += "int"; +#endif + compressed_type += ", A>"; + + // XXX + if (Thread == true) + compressed_type += " thread"; + compressed_type += '"'; + + std::ofstream file(filename, std::ios_base::app); + if (!file.good()) + throw std::runtime_error("write_viz_data cannot open filename"); + + file << compressed_type; + first_container = false; + } + + +void +write_viz_data(__gnu_test::time_counter& time, const char* filename) +{ + std::ofstream file(filename, std::ios_base::app); + if (!file.good()) + throw std::runtime_error("write_viz_data cannot open filename"); + + // Print out score in appropriate column. + const char tab('\t'); + int score = time.real_time(); + file << tab << score; +} + +void +write_viz_endl(const char* filename) +{ + std::ofstream file(filename, std::ios_base::app); + if (!file.good()) + throw std::runtime_error("write_viz_endl cannot open filename"); + file << std::endl; +} + + +// Function template, function objects for the tests. +template + struct value_type : public std::pair + { + inline value_type& operator++() + { + ++this->second; + return *this; + } + + inline operator TestType() const { return this->second; } + }; + +template + void + do_loop(); + +template + void* + do_thread(void* p = NULL) + { + do_loop(); + return p; + } + +template + void + test_container(const char* filename) + { + using namespace __gnu_test; + time_counter time; + resource_counter resource; + { + start_counters(time, resource); + if (!Thread) + { + // No threads, so run 4x. + do_loop(); + } + else + { +#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD) + pthread_t t1, t2, t3, t4; + pthread_create(&t1, 0, &do_thread, 0); + pthread_create(&t2, 0, &do_thread, 0); + pthread_create(&t3, 0, &do_thread, 0); + pthread_create(&t4, 0, &do_thread, 0); + + pthread_join(t1, NULL); + pthread_join(t2, NULL); + pthread_join(t3, NULL); + pthread_join(t4, NULL); +#endif + } + stop_counters(time, resource); + + // Detailed text data. + Container obj; + int status; + std::ostringstream comment; + comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), + 0, 0, &status); + report_header(filename, comment.str()); + report_performance("", "", time, resource); + + // Detailed data for visualization. + std::string vizfilename(filename); + vizfilename += ".dat"; + write_viz_data(time, vizfilename.c_str()); + } + } + +template + struct test_sequence + { + test_sequence(const char* filename) : _M_filename(filename) { } + + template + void + operator()(Container) + { + const int i = 20000; + test_container(_M_filename); + } + + private: + const char* _M_filename; + }; + + +inline std::string::size_type +sequence_find_container(std::string& type) +{ + const std::string::size_type npos = std::string::npos; + std::string::size_type n1 = type.find("vector"); + std::string::size_type n2 = type.find("list"); + std::string::size_type n3 = type.find("deque"); + std::string::size_type n4 = type.find("string"); + + if (n1 != npos || n2 != npos || n3 != npos || n4 != npos) + return std::min(std::min(n1, n2), std::min(n3, n4)); + else + throw std::runtime_error("sequence_find_container not found"); +} + +inline std::string::size_type +associative_find_container(std::string& type) +{ + using std::string; + string::size_type n1 = type.find("map"); + string::size_type n2 = type.find("set"); + if (n1 != string::npos || n2 != string::npos) + return std::min(n1, n2); + else + throw std::runtime_error("associative_find_container not found"); +} + #endif // _GLIBCXX_PERFORMANCE_H Index: testsuite/util/testsuite_common_types.h =================================================================== --- testsuite/util/testsuite_common_types.h (revision 134947) +++ testsuite/util/testsuite_common_types.h (working copy) @@ -31,7 +31,6 @@ #ifndef _TESTSUITE_COMMON_TYPES_H #define _TESTSUITE_COMMON_TYPES_H 1 -#include #include #include @@ -347,122 +346,4 @@ }; } // namespace __gnu_test - - -// Function template, function objects for the tests. -template - struct value_type : public std::pair - { - inline value_type& operator++() - { - ++this->second; - return *this; - } - - inline operator TestType() const { return this->second; } - }; - -template - void - do_loop(); - -template - void* - do_thread(void* p = NULL) - { - do_loop(); - return p; - } - -template - void - test_container(const char* filename) - { - using namespace __gnu_test; - time_counter time; - resource_counter resource; - { - start_counters(time, resource); - if (!Thread) - { - // No threads, so run 4x. - do_loop(); - } - else - { -#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD) - pthread_t t1, t2, t3, t4; - pthread_create(&t1, 0, &do_thread, 0); - pthread_create(&t2, 0, &do_thread, 0); - pthread_create(&t3, 0, &do_thread, 0); - pthread_create(&t4, 0, &do_thread, 0); - - pthread_join(t1, NULL); - pthread_join(t2, NULL); - pthread_join(t3, NULL); - pthread_join(t4, NULL); #endif - } - stop_counters(time, resource); - - // Detailed text data. - Container obj; - int status; - std::ostringstream comment; - comment << "type: " << abi::__cxa_demangle(typeid(obj).name(), - 0, 0, &status); - report_header(filename, comment.str()); - report_performance("", "", time, resource); - - // Detailed data for visualization. - std::string vizfilename(filename); - vizfilename += ".dat"; - write_viz_data(time, vizfilename.c_str()); - } - } - -template - struct test_sequence - { - test_sequence(const char* filename) : _M_filename(filename) { } - - template - void - operator()(Container) - { - const int i = 20000; - test_container(_M_filename); - } - - private: - const char* _M_filename; - }; - - -inline std::string::size_type -sequence_find_container(std::string& type) -{ - const std::string::size_type npos = std::string::npos; - std::string::size_type n1 = type.find("vector"); - std::string::size_type n2 = type.find("list"); - std::string::size_type n3 = type.find("deque"); - std::string::size_type n4 = type.find("string"); - - if (n1 != npos || n2 != npos || n3 != npos || n4 != npos) - return std::min(std::min(n1, n2), std::min(n3, n4)); - else - throw std::runtime_error("sequence_find_container not found"); -} - -inline std::string::size_type -associative_find_container(std::string& type) -{ - using std::string; - string::size_type n1 = type.find("map"); - string::size_type n2 = type.find("set"); - if (n1 != string::npos || n2 != string::npos) - return std::min(n1, n2); - else - throw std::runtime_error("associative_find_container not found"); -} -#endif