1

A significant portion of my program's runtime is being dedicated to std::__detail::_Map_base and I have no idea what that is referring to.

enter image description here

I searched around a bit on the internet, and it appears to be a struct of some sort, but I don't see how it's taking up time, let alone almost a fifth of it. What should I look for to reduce this time?

1 Answers1

2

I smell an EECS 281 Project here

For reference when I was an IA for this class, I got a lot of questions about this. This just means that a lot of your time has been spent in the internal methods of the map type. Try and cut down on expensive copies and repeated find operations. If you are accessing the map over and over again like the following code

if (m[key].something) {
    use(m[key]);
    cout << m[key];
}

try and change it to

auto& value = m[key];
if (value.something) {
    use(value);
    cout << value;
}

This will help you go from 3 expensive find operations to just 1. You can imagine how this can be helpful when you access a map lots of times in a loop.

Also take a look at Can the use of C++11's 'auto' improve performance? and make sure you are not making mistakes like that.

Curious
  • 20,870
  • 8
  • 61
  • 146