Thursday, January 21, 2010

Counting Lines of Code

Want some interesting metrics about your code? A nice little Windows utility called LOCmetrics could be just what you are looking for. When preparing for an application source code review, I usually need an estimate for the number of lines of code involved. I've found the numbers provided by development teams can vary significantly from what we actually see when we get the code. That is why I am going to start recommending they run LocMetrics.

LocMetrics has a simple GUI and works with C#, C++, Java, and SQL code. Run LocMetrics and it will dump out physical LOC, executable-physical LOC, and executable-logical LOC. Plus, you get bonus information like number of comment lines, blank lines, cyclomatic complexity (aka McCabe VG complexity) and LOC counts broken down by directory. The most important results are shown in the GUI itself and you get a HTML file containing more detail.

Here's a screen shot of the GUI:

I ran LocMetrics on a few Java libraries for comparison sake. Here are the results.

OWASP AntiSamy 1.3
Lines of Code = 4,576
Executable physical LOC = 1,972Executable logical LOC = 1,444
Cyclomatic complexity = 259

OWASP ESAPI 1.4.2
Lines of Code = 21,263
Executable physical LOC = 8,926
Executable logical LOC = 6,172

Cyclomatic complexity = 1,547

JSE 1.6.0_17 (java.* package only)
Lines of Code = 556,018Executable physical LOC = 200,567
Executable logical LOC = 136,076
Cyclomatic complexity = 38,106

3 comments:

romain 1/25/2010 8:28 AM  

What is the interest of having the cyclomatic complexity at the project level? Cannot see any interesting information related to that metric like that, even if you try to normalize it like CC/KLOC (but it's super useful at the function/method level)

Dave Ferguson 1/25/2010 11:38 AM  

Not sure what use it would be. I just wanted to mention that LocMetrics calculates it and it was fun to compare values for the different packages.

diniscruz 1/26/2010 6:15 AM  

This is a FUD comment, BUT, do you know who made this tool and what it is actually doing on your environment when it runs?

I went to http://www.locmetrics.com and the source code is not available and there is no contact details in there

Dinis

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP