30 #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 31 #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1 48 _M_resize(0), _M_list_cost(0), _M_vector_cost(0),
54 __object_info_base::__merge(__o);
55 _M_shift_count += __o._M_shift_count;
56 _M_iterate += __o._M_iterate;
57 _M_vector_cost += __o._M_vector_cost;
58 _M_list_cost += __o._M_list_cost;
59 _M_resize += __o._M_resize;
60 _M_max_size =
std::max( _M_max_size, __o._M_max_size);
64 __write(FILE* __f)
const 66 std::fprintf(__f,
"%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
67 _M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
72 {
return _M_list_cost - _M_vector_cost; }
79 <<
"change std::list to std::vector and its initial size from 0 to " 81 return __sstream.
str();
86 {
return _M_shift_count; }
90 {
return _M_iterate; }
94 {
return _M_list_cost; }
101 __set_list_cost(
float __lc)
102 { _M_list_cost = __lc; }
105 __set_vector_cost(
float __vc)
106 { _M_vector_cost = __vc; }
109 __opr_insert(std::size_t __shift, std::size_t __size)
111 _M_shift_count += __shift;
112 _M_max_size =
std::max(_M_max_size, __size);
116 __opr_iterate(
int __num)
117 { __gnu_cxx::__atomic_add(&_M_iterate, __num); }
120 __resize(std::size_t __from, std::size_t)
121 { _M_resize += __from; }
124 std::size_t _M_shift_count;
125 mutable _Atomic_word _M_iterate;
126 std::size_t _M_resize;
128 float _M_vector_cost;
129 std::size_t _M_max_size;
132 class __list2vector_stack_info
140 class __trace_list_to_vector
141 :
public __trace_base<__list2vector_info, __list2vector_stack_info>
144 __trace_list_to_vector()
146 { __id =
"list-to-vector"; }
148 ~__trace_list_to_vector() { }
154 float __vc = __vector_cost(__obj_info->__shift_count(),
155 __obj_info->__iterate());
156 float __lc = __list_cost(__obj_info->__shift_count(),
157 __obj_info->__iterate());
158 __obj_info->__set_vector_cost(__vc);
159 __obj_info->__set_list_cost(__lc);
160 __retire_object(__obj_info);
165 __vector_cost(std::size_t __shift, std::size_t __iterate)
169 * _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
171 * _GLIBCXX_PROFILE_DATA(__vector_iterate_cost_factor).__value);
175 __list_cost(std::size_t __shift, std::size_t __iterate)
178 * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
180 * _GLIBCXX_PROFILE_DATA(__list_iterate_cost_factor).__value);
186 __trace_list_to_vector_init()
187 { _GLIBCXX_PROFILE_DATA(_S_list_to_vector) =
new __trace_list_to_vector(); }
190 __trace_list_to_vector_free()
191 {
delete _GLIBCXX_PROFILE_DATA(_S_list_to_vector); }
194 __trace_list_to_vector_report(FILE* __f, __warning_vector_t& __warnings)
195 { __trace_report(_GLIBCXX_PROFILE_DATA(_S_list_to_vector), __f, __warnings); }
198 __trace_list_to_vector_construct()
203 if (!__reentrance_guard::__get_in())
207 return _GLIBCXX_PROFILE_DATA(_S_list_to_vector)
208 ->__add_object(__get_stack());
213 std::size_t __shift, std::size_t __size)
218 __obj_info->__opr_insert(__shift, __size);
229 __obj_info->__opr_iterate(1);
238 __obj_info->__set_invalid();
243 std::size_t __from, std::size_t __to)
248 __obj_info->__resize(__from, __to);
257 _GLIBCXX_PROFILE_DATA(_S_list_to_vector)->__destruct(__obj_info);
GNU profile code for public use.
Interface of the profiling runtime library.
bool __profcxx_init()
This function must be called by each instrumentation point.
Data structures to represent profiling traces.
A list-to-vector instrumentation line in the object table.
Data structures to represent a single profiling event.
Base class for a line in the object table.
Base class for all trace producers.
Controlling input and output for std::string.
__string_type str() const
Copying out the string buffer.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.