
SUMMARY : automatic tools for measuring C
Quote:
> >There is one metric gathering package that I know of. It can
> >be found at: gatekeeper.dec.com:/.2/usenet/comp.sources.unix/volume20/metrics/
> It included two different methods of measuring code complexity. One
> called halstead and one called mccabe.
If metrics are a new game for you, I would suggest spending some time in
deciding what you want to collect. Both Halstead and McCabe are fairly
abstract, so if you don't know what you're looking for neither of these
philosophies may provide it. My organization uses the following as part
of our entry criteria for Fagan Inspections.
________________________________________________
| | | Complexity |
|Module Name| Function Name| _________________|
| | | McCabe Density|
|___________|_______________|__________________|
|test1.c | func1 | 1 1.00 |
| | func2 | 2 0.67 |
| | Other | N/A N/A |
|___________|_______________|__________________|
|test2.c | Other | N/A N/A |
|___________|_______________|__________________|
|test3.c | func3 | 3 1.00 |
| | func4 | 1 1.00 |
| | Other | N/A N/A |
|___________|_______________|__________________|
|Totals | | N/A N/A |
|Mean | | 1.75 0.92 |
|Std Dev | | 0.25 0.08 |
|Minimum | | 1.50 0.83 |
|Maximum | | 2.00 1.00 |
|___________|_______________|__________________|
_________________________________________________________________
| | | Halstead Metrics |
|Module Name| Function Name| __________________________________|
| | | Volume Length Purity Effort|
|___________|_______________|___________________________________|
|test1.c | func1 | 25 9 1.42 50 |
| | func2 | 59 18 1.31 221 |
| | Other | N/A N/A N/A N/A |
|___________|_______________|___________________________________|
|test2.c | Other | N/A N/A N/A N/A |
|___________|_______________|___________________________________|
|test3.c | func3 | 183 44 1.30 1281 |
| | func4 | 15 6 1.67 30 |
| | Other | N/A N/A N/A N/A |
|___________|_______________|___________________________________|
|Totals | | 282 77 N/A N/A |
|Mean | | 141.00 38.50 1.42 395.56|
|Std Dev | | 57.00 11.50 0.06 259.94|
|Minimum | | 84 27 N/A N/A |
|Maximum | | 198 50 N/A N/A |
|___________|_______________|___________________________________|
Each of the above outputs were generated using an in-house PERL script.
I am sure available tools provide similar information.
The real risk behind collecting either of these metrics is transfering
their importance to the troops. IMHO (most humble), metrics should be
used to measure something strickly for the purpose of improving future
assignments. Realizing the Purity of a particular function does not
lend itself to reevaluation and scrutiny.
Just my $0.02. I'll claim this post is valid in this newsgroup as
metrics evaluation is just as imperative as having good C code.
Doug