guide
guide copied to clipboard
C++: linters and profilers
Good linters perhaps should be listed under a separate subheader under Style:
- cpplint (is mentioned already): checks (mostly?) for style, following the Google style guide.
- cppcheck: does static analysis, checks for bugs.
These can (and perhaps should, though cpplint can be debated, I guess) be used simultaneously, they are complementary.
Profilers:
- cachegrind
- gprof
Good article explaining pitfalls in using profilers: http://yosefk.com/blog/how-profilers-lie-the-cases-of-gprof-and-kcachegrind.html
Also perf, the Linux kernel profiler is very good, if a bit difficult to use due to not overly abundant documentation. There's a CppCon 2015 presentation on it that is useful, I'll see if I can dig up some links.
I've tried cpplint and cppcheck, but they didn't find any errors in my code. Especially cpplint seems to check mainly for mistakes that you won't make if you use proper C++. Still, could be useful for if you're dealing with crappy existing code.
Especially cpplint seems to check mainly for mistakes that you won't make if you use proper C++
So it does exactly what you would hope for ;-)
Remember: the target of this information is also less experienced programmers.
Another useful blog on pros/cons of different profilers can be found here. In addition to these tools, there is an interesting one called PAPI using hardware performance counters but I haven't used it (yet).
Sweet, didn't know about PAPI but it looks pretty awesome. I think I'll try that on my forest fragmentation code next time a round tuit comes, I'll let you know how it goes :).
@jhidding and @egpbos -- is this issue still relevant? Does the guide contain sufficient detail on these topics (or points to resources on these topics).
No time to review now, can we try again at the next sprint? :)
Sure.