possiblyasleep
Programmer
I have been analyzing project load times of a program we are currently developing, and have been trying to figure out why it is going slower than we think it should. I have narrowed the problem down to a single line of code, but unfortunately can not account for why it is behaving as it is. The line is as follows:
This line generally takes 0.01 - 0.02 seconds to execute, but occaisionally, it can take upwards of 0.6 seconds to finish. (I'm using the hardware performance counter to get timings). This wouldn't seem that bad, except that that line executes 10,000+ times while loading a project.
The pointer is a COM IP Pointer, and is automatically addreffed, which takes less than 0.001 seconds. The data structure being created is not complex, and its constructor and base class constructors should not take more than a few thousandths of a second to execute (though this is an assumption, I'm having trouble actually test it). The amount of memory allocated by the new is around 320 bytes. The constructor's argument (pRefPropertyName) is a std::wstring that is passed into the function containing this line.
My main problem is that I can't understand why it would vary so much. I have ensured that no other threads are interfering. My only hypotheses are that it is occaisionally running out of heap and needing to allocate more, or that there is some slowdown due to the template. However, even if I statically allocate enough memory at startup, it still runs into those slowdowns. I am not sure how to test to see if the template is causing the problem.
If any one has run into similar issues, or has any hint for what to look at, or where to make an optimization, please let me know. If you need more information please ask.
Thank you.
Code:
cAddRefPtr< cProperty<T> > newProperty = new cProperty<T>(pRefPropertyName);
This line generally takes 0.01 - 0.02 seconds to execute, but occaisionally, it can take upwards of 0.6 seconds to finish. (I'm using the hardware performance counter to get timings). This wouldn't seem that bad, except that that line executes 10,000+ times while loading a project.
The pointer is a COM IP Pointer, and is automatically addreffed, which takes less than 0.001 seconds. The data structure being created is not complex, and its constructor and base class constructors should not take more than a few thousandths of a second to execute (though this is an assumption, I'm having trouble actually test it). The amount of memory allocated by the new is around 320 bytes. The constructor's argument (pRefPropertyName) is a std::wstring that is passed into the function containing this line.
My main problem is that I can't understand why it would vary so much. I have ensured that no other threads are interfering. My only hypotheses are that it is occaisionally running out of heap and needing to allocate more, or that there is some slowdown due to the template. However, even if I statically allocate enough memory at startup, it still runs into those slowdowns. I am not sure how to test to see if the template is causing the problem.
If any one has run into similar issues, or has any hint for what to look at, or where to make an optimization, please let me know. If you need more information please ask.
Thank you.