1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
// 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 <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
|