30 #ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H
31 #define _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H 1
37 namespace __gnu_profile
45 : _M_shift_count(0), _M_iterate(0), _M_resize(0), _M_list_cost(0),
46 _M_vector_cost(0), _M_valid(
true) { }
50 _M_resize(0), _M_list_cost(0), _M_vector_cost(0), _M_valid(
true) { }
56 _M_iterate(__o._M_iterate), _M_resize(__o._M_resize),
57 _M_list_cost(__o._M_list_cost), _M_vector_cost(__o._M_vector_cost),
58 _M_valid(__o._M_valid) { }
63 _M_shift_count += __o._M_shift_count;
64 _M_iterate += __o._M_iterate;
65 _M_vector_cost += __o._M_vector_cost;
66 _M_list_cost += __o._M_list_cost;
67 _M_valid &= __o._M_valid;
68 _M_resize += __o._M_resize;
72 __write(FILE* __f)
const
74 std::fprintf(__f,
"%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
75 _M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
80 {
return _M_vector_cost - _M_list_cost; }
84 {
return "change std::vector to std::list"; }
88 {
return _M_shift_count; }
92 {
return _M_iterate; }
96 {
return _M_list_cost; }
100 {
return _M_resize; }
103 __set_list_cost(
float __lc)
104 { _M_list_cost = __lc; }
107 __set_vector_cost(
float __vc)
108 { _M_vector_cost = __vc; }
116 { _M_valid =
false; }
119 __opr_insert(std::size_t __pos, std::size_t __num)
120 { _M_shift_count += __num - __pos; }
123 __opr_iterate(std::size_t __num)
124 { _M_iterate += __num; }
127 __resize(std::size_t __from, std::size_t)
128 { _M_resize += __from; }
131 __opr_find(std::size_t __size)
134 _M_iterate += 3.0 / 4.0 * __size;
138 std::size_t _M_shift_count;
139 std::size_t _M_iterate;
140 std::size_t _M_resize;
142 float _M_vector_cost;
159 :
public __trace_base<__vector2list_info, __vector2list_stack_info>
164 { __id =
"vector-to-list"; }
170 __insert(__object_t __obj, __stack_t __stack)
175 __destruct(
const void* __obj)
184 float __vc = __vector_cost(__res->__shift_count(), __res->__iterate(),
186 float __lc = __list_cost(__res->__shift_count(), __res->__iterate(),
188 __res->__set_vector_cost(__vc);
189 __res->__set_list_cost(__lc);
191 __retire_object(__obj);
200 __opr_insert(
const void* __obj, std::size_t __pos, std::size_t __num)
204 __res->__opr_insert(__pos, __num);
208 __opr_iterate(
const void* __obj, std::size_t __num)
212 __res->__opr_iterate(__num);
216 __invalid_operator(
const void* __obj)
220 __res->__set_invalid();
224 __resize(
const void* __obj, std::size_t __from, std::size_t __to)
228 __res->__resize(__from, __to);
232 __vector_cost(std::size_t __shift, std::size_t __iterate,
233 std::size_t __resize)
236 * _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
238 * _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value
240 * _GLIBCXX_PROFILE_DATA(__vector_resize_cost_factor).__value);
244 __list_cost(std::size_t __shift, std::size_t __iterate,
245 std::size_t __resize)
248 * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
250 * _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value
252 * _GLIBCXX_PROFILE_DATA(__list_resize_cost_factor).__value);
256 __opr_find(
const void* __obj, std::size_t __size)
260 __res->__opr_find(__size);
266 __trace_vector_to_list_init()
270 __trace_vector_to_list_report(FILE* __f, __warning_vector_t& __warnings)
272 if (_GLIBCXX_PROFILE_DATA(_S_vector_to_list))
274 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->
275 __collect_warnings(__warnings);
276 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__write(__f);
281 __trace_vector_to_list_construct(
const void* __obj)
286 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__insert(__obj, __get_stack());
290 __trace_vector_to_list_destruct(
const void* __obj)
295 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__destruct(__obj);
299 __trace_vector_to_list_insert(
const void* __obj, std::size_t __pos,
305 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_insert(__obj, __pos,
310 __trace_vector_to_list_iterate(
const void* __obj, std::size_t __num = 1)
315 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_iterate(__obj, __num);
319 __trace_vector_to_list_invalid_operator(
const void* __obj)
324 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__invalid_operator(__obj);
328 __trace_vector_to_list_resize(
const void* __obj, std::size_t __from,
334 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__resize(__obj, __from, __to);
338 __trace_vector_to_list_find(
const void* __obj, std::size_t __size)
343 _GLIBCXX_PROFILE_DATA(_S_vector_to_list)->__opr_find(__obj, __size);
Data structures to represent profiling traces.
A vector-to-list instrumentation line in the stack table.
Base class for a line in the object table.
bool __profcxx_init()
This function must be called by each instrumentation point.
A vector-to-list instrumentation line in the object table.
Interface of the profiling runtime library.
Base class for all trace producers.
Data structures to represent a single profiling event.
Vector-to-list instrumentation producer.