guide icon indicating copy to clipboard operation
guide copied to clipboard

C++: linters and profilers

Open egpbos opened this issue 8 years ago • 7 comments

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

egpbos avatar Jun 27 '16 16:06 egpbos

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.

LourensVeen avatar Jun 28 '16 08:06 LourensVeen

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.

nielsdrost avatar Jun 28 '16 10:06 nielsdrost

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).

arnikz avatar Jun 20 '17 12:06 arnikz

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 :).

LourensVeen avatar Jun 20 '17 12:06 LourensVeen

@jhidding and @egpbos -- is this issue still relevant? Does the guide contain sufficient detail on these topics (or points to resources on these topics).

c-martinez avatar Sep 09 '20 13:09 c-martinez

No time to review now, can we try again at the next sprint? :)

egpbos avatar Sep 10 '20 11:09 egpbos

Sure.

c-martinez avatar Sep 10 '20 12:09 c-martinez