30 #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H
31 #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1
39 namespace __gnu_profile
47 : _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0),
48 _M_vector_cost(0), _M_valid(
true), _M_max_size(0) { }
52 _M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(
true),
59 _M_iterate(__o._M_iterate), _M_resize(__o._M_resize),
60 _M_list_cost(__o._M_list_cost), _M_vector_cost(__o._M_vector_cost),
61 _M_valid(__o._M_valid), _M_max_size(__o._M_max_size) { }
66 _M_shift_count += __o._M_shift_count;
67 _M_iterate += __o._M_iterate;
68 _M_vector_cost += __o._M_vector_cost;
69 _M_list_cost += __o._M_list_cost;
70 _M_valid &= __o._M_valid;
71 _M_resize += __o._M_resize;
72 _M_max_size =
std::max( _M_max_size, __o._M_max_size);
76 __write(FILE* __f)
const
78 std::fprintf(__f,
"%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
79 _M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
84 {
return _M_list_cost - _M_vector_cost; }
91 <<
"change std::list to std::vector and its initial size from 0 to "
93 return __sstream.
str();
98 {
return _M_shift_count; }
102 {
return _M_iterate; }
106 {
return _M_list_cost; }
110 {
return _M_resize; }
113 __set_list_cost(
float __lc)
114 { _M_list_cost = __lc; }
117 __set_vector_cost(
float __vc)
118 { _M_vector_cost = __vc; }
126 { _M_valid =
false; }
129 __opr_insert(std::size_t __shift, std::size_t __size)
131 _M_shift_count += __shift;
132 _M_max_size =
std::max(_M_max_size, __size);
136 __opr_iterate(std::size_t __num)
137 { _M_iterate += __num;}
140 __resize(std::size_t __from, std::size_t)
141 { _M_resize += __from; }
144 std::size_t _M_shift_count;
145 std::size_t _M_iterate;
146 std::size_t _M_resize;
148 float _M_vector_cost;
150 std::size_t _M_max_size;
153 class __list2vector_stack_info
161 class __trace_list_to_vector
162 :
public __trace_base<__list2vector_info, __list2vector_stack_info>
165 __trace_list_to_vector()
166 : __trace_base<__list2vector_info, __list2vector_stack_info>()
167 { __id =
"list-to-vector"; }
169 ~__trace_list_to_vector() { }
173 __insert(__object_t __obj, __stack_t __stack)
174 { __add_object(__obj, __list2vector_info(__stack)); }
178 __destruct(
const void* __obj)
183 __list2vector_info* __res = __get_object_info(__obj);
187 float __vc = __vector_cost(__res->__shift_count(), __res->__iterate());
188 float __lc = __list_cost(__res->__shift_count(), __res->__iterate());
189 __res->__set_vector_cost(__vc);
190 __res->__set_list_cost(__lc);
191 __retire_object(__obj);
195 __list2vector_info* __find(
const void* __obj);
199 __opr_insert(
const void* __obj, std::size_t __shift, std::size_t __size)
201 __list2vector_info* __res = __get_object_info(__obj);
203 __res->__opr_insert(__shift, __size);
207 __opr_iterate(
const void* __obj, std::size_t __num)
209 __list2vector_info* __res = __get_object_info(__obj);
211 __res->__opr_iterate(__num);
215 __invalid_operator(
const void* __obj)
217 __list2vector_info* __res = __get_object_info(__obj);
219 __res->__set_invalid();
223 __resize(
const void* __obj, std::size_t __from, std::size_t __to)
225 __list2vector_info* __res = __get_object_info(__obj);
227 __res->__resize(__from, __to);
231 __vector_cost(std::size_t __shift, std::size_t __iterate)
235 * _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
237 * _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value);
241 __list_cost(std::size_t __shift, std::size_t __iterate)
244 * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
246 * _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value);
252 __trace_list_to_vector_init()
253 { _GLIBCXX_PROFILE_DATA(_S_list_to_vector) =
new __trace_list_to_vector(); }
256 __trace_list_to_vector_report(FILE* __f, __warning_vector_t& __warnings)
258 if (_GLIBCXX_PROFILE_DATA(_S_list_to_vector))
260 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->
261 __collect_warnings(__warnings);
262 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__write(__f);
267 __trace_list_to_vector_construct(
const void* __obj)
272 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__insert(__obj, __get_stack());
276 __trace_list_to_vector_destruct(
const void* __obj)
281 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__destruct(__obj);
285 __trace_list_to_vector_insert(
const void* __obj,
286 std::size_t __shift, std::size_t __size)
291 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__opr_insert(__obj, __shift,
296 __trace_list_to_vector_iterate(
const void* __obj, std::size_t __num = 1)
301 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__opr_iterate(__obj, __num);
305 __trace_list_to_vector_invalid_operator(
const void* __obj)
310 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__invalid_operator(__obj);
314 __trace_list_to_vector_resize(
const void* __obj,
315 std::size_t __from, std::size_t __to)
320 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__resize(__obj, __from, __to);
Data structures to represent profiling traces.
A list-to-vector instrumentation line in the object table.
Base class for a line in the object table.
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
bool __profcxx_init()
This function must be called by each instrumentation point.
__string_type str() const
Copying out the string buffer.
Controlling input and output for std::string.
Interface of the profiling runtime library.
Data structures to represent a single profiling event.