1 // Copyright (C) 2005 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 2, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // As a special exception, you may use this file as part of a free software
20 // library without restriction. Specifically, if other files instantiate
21 // templates or use macros or inline functions from this file, or you compile
22 // this file and link it with other files to produce an executable, this
23 // file does not by itself cause the resulting executable to be covered by
24 // the GNU General Public License. This exception does not however
25 // invalidate any other reasons why the executable file might be covered by
26 // the GNU General Public License.
33 #include <testsuite_performance.h>
35 // Ah, we wish it wasn't so...
36 bool first_container
= false;
37 extern const char* filename
;
39 typedef std::string::size_type (*callback_type
) (std::string
&);
41 template<typename Container
, int Iter
, bool Thread
>
43 write_viz_container(callback_type find_container
, const char* filename
)
45 typedef std::string string
;
50 std::ostringstream title
;
52 std::string
titlename(filename
);
53 std::string::size_type n
= titlename
.find('.');
54 if (n
!= string::npos
)
55 titlename
= std::string(titlename
.begin(), titlename
.begin() + n
);
63 std::boolalpha(title
);
68 titlename
+= ".title";
69 std::ofstream
titlefile(titlename
.c_str());
70 if (!titlefile
.good())
71 throw std::runtime_error("write_viz_data cannot open titlename");
72 titlefile
<< title
.str() << std::endl
;
75 // Create compressed type name.
78 std::string
type(abi::__cxa_demangle(typeid(obj
).name(), 0, 0, &status
));
80 // Extract fully-qualified typename.
81 // Assumes "set" or "map" are uniquely determinate.
82 string::iterator beg
= type
.begin();
84 string::size_type n
= (*find_container
)(type
);
86 // Find start of fully-qualified name.
87 // Assume map, find end.
88 string::size_type nend
= type
.find('<', n
);
89 if (nend
!= string::npos
)
90 end
= type
.begin() + nend
;
92 string compressed_type
;
93 compressed_type
+= '"';
94 compressed_type
+= string(beg
, end
);
95 compressed_type
+= '<';
97 typename
Container::key_type v
;
98 compressed_type
+= typeid(v
).name();
100 compressed_type
+= "int";
102 compressed_type
+= ", A>";
106 compressed_type
+= " thread";
107 compressed_type
+= '"';
109 std::ofstream
file(filename
, std::ios_base::app
);
111 throw std::runtime_error("write_viz_data cannot open filename");
113 file
<< compressed_type
;
114 first_container
= false;
119 write_viz_data(__gnu_test::time_counter
& time
, const char* filename
)
121 std::ofstream
file(filename
, std::ios_base::app
);
123 throw std::runtime_error("write_viz_data cannot open filename");
125 // Print out score in appropriate column.
126 const char tab('\t');
127 int score
= time
.real_time();
128 file
<< tab
<< score
;
132 write_viz_endl(const char* filename
)
134 std::ofstream
file(filename
, std::ios_base::app
);
136 throw std::runtime_error("write_viz_endl cannot open filename");
143 write_viz_container
<container_type
, Iter
, Thread
>(&sequence_find_container
,
149 write_viz_endl(filename
)