diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2008-05-05 17:22:02 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2008-05-05 17:22:02 +0000 |
commit | 1d3d8fff365549b74d58dde19588759953346920 (patch) | |
tree | 746ae84ebe415264b227c9df47decae6356f1fe4 /libstdc++-v3 | |
parent | ce72d1aa87e92f05b076bbfe57024918380904cc (diff) | |
download | gcc-1d3d8fff365549b74d58dde19588759953346920.zip gcc-1d3d8fff365549b74d58dde19588759953346920.tar.gz gcc-1d3d8fff365549b74d58dde19588759953346920.tar.bz2 |
testsuite_visualization.h: Move contents into...
2008-05-05 Benjamin Kosnik <bkoz@redhat.com>
* 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.
From-SVN: r134949
Diffstat (limited to 'libstdc++-v3')
19 files changed, 272 insertions, 286 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 864a580..ff9ac66 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,31 @@ 2008-05-05 Benjamin Kosnik <bkoz@redhat.com> + * 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. + +2008-05-05 Benjamin Kosnik <bkoz@redhat.com> + * 20_util/make_signed/requirements/typedefs-1.cc: Correct requirements. * 20_util/make_unsigned/requirements/typedefs-1.cc: Same. diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc index 43530986..a22a558 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc @@ -38,7 +38,7 @@ int main() 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 } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc index 011933a..4912518 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc @@ -38,7 +38,7 @@ int main() 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 } diff --git a/libstdc++-v3/testsuite/performance/23_containers/create/map.cc b/libstdc++-v3/testsuite/performance/23_containers/create/map.cc index 5049e1a..1ec2061 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/create/map.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/create/map.cc @@ -27,7 +27,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc b/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc index 97ea3af..c9259c0 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/create_from_sorted/set.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc b/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc index 7a47f32..063075f 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/create_sort/list.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/find/map.cc b/libstdc++-v3/testsuite/performance/23_containers/find/map.cc index e6c2c79..6d09d03 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/find/map.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/find/map.cc @@ -27,7 +27,7 @@ // 2004-03-11 Dhruv Matani <dhruvbird@HotPOP.com> -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/index/map.cc b/libstdc++-v3/testsuite/performance/23_containers/index/map.cc index 386890d..e08b7d8 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/index/map.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/index/map.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> // libstdc++/13823 recast for this testing framework template<typename Container, int Iter> diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc b/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc index b3f8f71..a047f99 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/insert/associative.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc b/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc index 7023332..41faac1 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/insert/sequence.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc b/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc index ee48ce2..f3a29d0 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/insert_erase/associative.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc b/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc index 72b1921..201edd9 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/insert_from_sorted/set.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc index 841cdf0..d0e1f2c 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/associative.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> typedef int test_type; diff --git a/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc index 1590c97..80c200f 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/producer_consumer/sequence.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> typedef int test_type; diff --git a/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc b/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc index 14b42b4..71f66fd 100644 --- a/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc +++ b/libstdc++-v3/testsuite/performance/23_containers/sort_search/list.cc @@ -25,7 +25,7 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -#include <testsuite_common_types.h> +#include <testsuite_performance.h> template<typename Container, int Iter> void diff --git a/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc b/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc index d316cf8..814de70 100644 --- a/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc +++ b/libstdc++-v3/testsuite/performance/25_algorithms/search_n.cc @@ -53,7 +53,7 @@ main(void) array[i] = (match != 0) ? 1 : 0; if(--match < 0) match = rand() % (match_length - 1); } - test_container<int, forward_iterator_wrapper> fcon(array, array + length); + __gnu_test::test_container<int, forward_iterator_wrapper> 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 @@ main(void) report_performance(__FILE__, "forward iterator", time, resource); clear_counters(time, resource); - test_container<int, random_access_iterator_wrapper> rcon(array, array + length); + __gnu_test::test_container<int, random_access_iterator_wrapper> rcon(array, array + length); start_counters(time, resource); for(int i = 0; i < 100; i++) search_n(rcon.begin(), rcon.end(), 10, 1); diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h index bd9e76d..35bd907 100644 --- a/libstdc++-v3/testsuite/util/testsuite_common_types.h +++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h @@ -31,7 +31,6 @@ #ifndef _TESTSUITE_COMMON_TYPES_H #define _TESTSUITE_COMMON_TYPES_H 1 -#include <testsuite_visualization.h> #include <ext/typelist.h> #include <ext/new_allocator.h> @@ -347,122 +346,4 @@ namespace __gnu_test }; } // namespace __gnu_test - - -// Function template, function objects for the tests. -template<typename TestType> - struct value_type : public std::pair<const TestType, TestType> - { - inline value_type& operator++() - { - ++this->second; - return *this; - } - - inline operator TestType() const { return this->second; } - }; - -template<typename Container, int Iter> - void - do_loop(); - -template<typename Container, int Iter> - void* - do_thread(void* p = NULL) - { - do_loop<Container, Iter>(); - return p; - } - -template<typename Container, int Iter, bool Thread> - 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<Container, Iter * 4>(); - } - else - { -#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD) - pthread_t t1, t2, t3, t4; - pthread_create(&t1, 0, &do_thread<Container, Iter>, 0); - pthread_create(&t2, 0, &do_thread<Container, Iter>, 0); - pthread_create(&t3, 0, &do_thread<Container, Iter>, 0); - pthread_create(&t4, 0, &do_thread<Container, Iter>, 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<bool Thread> - struct test_sequence - { - test_sequence(const char* filename) : _M_filename(filename) { } - - template<class Container> - void - operator()(Container) - { - const int i = 20000; - test_container<Container, i, Thread>(_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 diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h index ad873ed..2466518 100644 --- a/libstdc++-v3/testsuite/util/testsuite_performance.h +++ b/libstdc++-v3/testsuite/util/testsuite_performance.h @@ -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 <string> #include <fstream> #include <iomanip> +#include <typeinfo> +#include <stdexcept> +#include <sstream> +#include <cxxabi.h> +#include <testsuite_common_types.h> #ifdef __linux__ #include <malloc.h> @@ -260,5 +265,229 @@ namespace __gnu_test } } // 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<typename Container, int Iter, bool Thread> + 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<typename TestType> + struct value_type : public std::pair<const TestType, TestType> + { + inline value_type& operator++() + { + ++this->second; + return *this; + } + + inline operator TestType() const { return this->second; } + }; + +template<typename Container, int Iter> + void + do_loop(); + +template<typename Container, int Iter> + void* + do_thread(void* p = NULL) + { + do_loop<Container, Iter>(); + return p; + } + +template<typename Container, int Iter, bool Thread> + 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<Container, Iter * 4>(); + } + else + { +#if defined (_GLIBCXX_GCC_GTHR_POSIX_H) && !defined (NOTHREAD) + pthread_t t1, t2, t3, t4; + pthread_create(&t1, 0, &do_thread<Container, Iter>, 0); + pthread_create(&t2, 0, &do_thread<Container, Iter>, 0); + pthread_create(&t3, 0, &do_thread<Container, Iter>, 0); + pthread_create(&t4, 0, &do_thread<Container, Iter>, 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<bool Thread> + struct test_sequence + { + test_sequence(const char* filename) : _M_filename(filename) { } + + template<class Container> + void + operator()(Container) + { + const int i = 20000; + test_container<Container, i, Thread>(_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 diff --git a/libstdc++-v3/testsuite/util/testsuite_visualization.h b/libstdc++-v3/testsuite/util/testsuite_visualization.h deleted file mode 100644 index 0e27576..0000000 --- a/libstdc++-v3/testsuite/util/testsuite_visualization.h +++ /dev/null @@ -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 <typeinfo> -#include <stdexcept> -#include <sstream> -#include <fstream> -#include <cxxabi.h> -#include <testsuite_performance.h> - -// 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<typename Container, int Iter, bool Thread> - 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<container_type, Iter, Thread>(&sequence_find_container, - filename); -#endif - -#if 0 -// dtor -write_viz_endl(filename) -#endif |