several optimizations#163
Conversation
|
do you have some real life measurements? |
|
Running with -j1 to see the actual impact - the library I used to profile and some random ones. openni-sensor-primesense s390-tools gabedit Edit: I just realized I had two local optimization still enabled. Need to re-test without them...also compared to the actual daca@home runs I forgot to adjust the |
|
Okay, now with just the optimization ins this PR. It does not effect all scans. openni-sensor-primesense 4.7 5.1 Strangely gabedit gives about 2000 warnings less with the changes, so I need to look into this. |
| while (istr.good()) { | ||
| currentToken += ch; | ||
| if (currentToken.size() >= 4U && endsWith(currentToken, "*/")) | ||
| static const std::string commentEnd("*/"); |
There was a problem hiding this comment.
as far as I remember we try to make simplecpp threadsafe. So a static local variable should be avoided.
There was a problem hiding this comment.
Good point. Would a global one be okay?
| void simplecpp::Location::adjust(const std::string &str) | ||
| { | ||
| if (str.find_first_of("\r\n") == std::string::npos) { | ||
| if (!strpbrk(str.c_str(), "\r\n")) { |
There was a problem hiding this comment.
I find it strange that this would be an optimisation. Is strpbrk optimised better?
However I think it obfuscates the code. I do not intuitively know how strpbrk works.
There was a problem hiding this comment.
callgrind showed and there's this
https://www.codeproject.com/Articles/18473/find-first-of-A-performance-pitfall-among-the-STL#A30. I used the latest GCC so it seems this is still true although that article is 12 years old.
strpbrk is the same as find_first_of.
There was a problem hiding this comment.
Running simplecpp on -q -Ilib lib/valueflow.cpp:
GCC 335,129,681 -> 325,111,787
Clang 323,433,151 -> 313,133,608
I filed a ticket about this https://trac.cppcheck.net/ticket/10777.
|
I tried some other measurements and those were a inconclusive. I will look into this in the next days. |
|
Running |
… std::string::find_first_of()
…ding run-time string creation
d5e2443 to
82d1c89
Compare
|
Using baseline Location::adjust() endsWith() lastLine() unordered_map flags memchr flags copy ctor FYI about a third of the instructions is made up by the new/delete of the |
No description provided.