30 #ifndef _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H
31 #define _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H 1
40 __log2(std::size_t __size)
42 for (
int __bit_count =
sizeof(std::size_t) - 1; __bit_count >= 0;
44 if ((2 << __bit_count) & __size)
50 __map_insert_cost(std::size_t __size)
51 {
return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value
52 * static_cast<float>(__log2(__size))); }
55 __map_erase_cost(std::size_t __size)
56 {
return (_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor).__value
57 * static_cast<float>(__log2(__size))); }
60 __map_find_cost(std::size_t __size)
61 {
return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value
62 * static_cast<float>(__log2(__size))); }
71 : _M_insert(0), _M_erase(0), _M_find(0), _M_iterate(0),
72 _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(
true) { }
76 _M_iterate(0), _M_umap_cost(0.0), _M_map_cost(0.0), _M_valid(
true) { }
82 _M_erase(__o._M_erase), _M_find(__o._M_find),
83 _M_iterate(__o._M_iterate), _M_umap_cost(__o._M_umap_cost),
84 _M_map_cost(__o._M_map_cost), _M_valid(__o._M_valid) { }
89 _M_insert += __o._M_insert;
90 _M_erase += __o._M_erase;
91 _M_find += __o._M_find;
92 _M_umap_cost += __o._M_umap_cost;
93 _M_map_cost += __o._M_map_cost;
94 _M_valid &= __o._M_valid;
98 __write(FILE* __f)
const
100 std::fprintf(__f,
"%Zu %Zu %Zu %Zu %.0f %.0f %s\n",
101 _M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost,
102 _M_umap_cost, _M_valid ?
"valid" :
"invalid");
107 {
return _M_map_cost - _M_umap_cost; }
111 {
return "change std::map to std::unordered_map"; }
114 __record_insert(std::size_t __size, std::size_t __count)
116 _M_insert += __count;
117 _M_map_cost += __count * __map_insert_cost(__size);
120 * _GLIBCXX_PROFILE_DATA(__umap_insert_cost_factor).__value);
124 __record_erase(std::size_t __size, std::size_t __count)
127 _M_map_cost += __count * __map_erase_cost(__size);
130 * _GLIBCXX_PROFILE_DATA(__umap_erase_cost_factor).__value);
134 __record_find(std::size_t __size)
137 _M_map_cost += __map_find_cost(__size);
138 _M_umap_cost += _GLIBCXX_PROFILE_DATA(__umap_find_cost_factor).__value;
142 __record_iterate(std::size_t __count)
144 _M_iterate += __count;
147 * _GLIBCXX_PROFILE_DATA(__map_iterate_cost_factor).__value);
150 * _GLIBCXX_PROFILE_DATA(__umap_iterate_cost_factor).__value);
154 __record_invalidate()
155 { _M_valid =
false; }
158 std::size_t _M_insert;
159 std::size_t _M_erase;
161 std::size_t _M_iterate;
180 :
public __trace_base<__map2umap_info, __map2umap_stack_info>
185 { __id =
"map-to-unordered-map"; }
189 __trace_map_to_unordered_map_init()
193 __trace_map_to_unordered_map_report(FILE* __f,
194 __warning_vector_t& __warnings)
196 if (_GLIBCXX_PROFILE_DATA(_S_map2umap))
198 _GLIBCXX_PROFILE_DATA(_S_map2umap)->__collect_warnings(__warnings);
199 _GLIBCXX_PROFILE_DATA(_S_map2umap)->__write(__f);
204 __trace_map_to_unordered_map_construct(
const void* __obj)
209 _GLIBCXX_PROFILE_DATA(_S_map2umap)->
210 __add_object(__obj, __map2umap_info(__get_stack()));
214 __trace_map_to_unordered_map_destruct(
const void* __obj)
219 _GLIBCXX_PROFILE_DATA(_S_map2umap)->__retire_object(__obj);
223 __trace_map_to_unordered_map_insert(
const void* __obj,
224 std::size_t __size, std::size_t __count)
229 __map2umap_info* __info
230 = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
233 __info->__record_insert(__size, __count);
237 __trace_map_to_unordered_map_erase(
const void* __obj,
238 std::size_t __size, std::size_t __count)
243 __map2umap_info* __info
244 = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
247 __info->__record_erase(__size, __count);
251 __trace_map_to_unordered_map_find(
const void* __obj, std::size_t __size)
256 __map2umap_info* __info
257 = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
260 __info->__record_find(__size);
264 __trace_map_to_unordered_map_iterate(
const void* __obj, std::size_t __count)
269 __map2umap_info* __info
270 = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
273 __info->__record_iterate(__count);
277 __trace_map_to_unordered_map_invalidate(
const void* __obj)
282 __map2umap_info* __info
283 = _GLIBCXX_PROFILE_DATA(_S_map2umap)->__get_object_info(__obj);
286 __info->__record_invalidate();
bool __profcxx_init()
This function must be called by each instrumentation point.
Base class for all trace producers.
Interface of the profiling runtime library.
A map-to-unordered_map instrumentation line in the stack table.
Data structures to represent a single profiling event.
A map-to-unordered_map instrumentation line in the object table.
Data structures to represent profiling traces.
GNU profile code for public use.
Base class for a line in the object table.
Map-to-unordered_map instrumentation producer.