-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
108 lines (75 loc) · 3.36 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
GNOCCHI - A COMPLEXITY ANALYSER FOR C++
Gnocchi calculates cyclomatic and the NPATH complexity measures.
It reads the coverage information produced by GCC and determines the
complexity of all functions. If code is compiled with -fprofile-arcs
or -ftest-coverage (depending on compiler version) GCC creates a .gcno
file for every object file.
Gnocchi is free software.
See the end of the file for license conditions.
EXAMPLE SESSION
Running gnocchi on its own build tree
./gnocchi --threshold 20 ~/gnocchi/trunk/
/usr/include/c++/4.1.2/bits/basic_string.tcc:137: mccabe=7 npath=42
/home/epronk/gnocchi/trunk/test_input.c:101: mccabe=9 npath=80
/home/epronk/gnocchi/trunk/main.cpp:129: mccabe=11 npath=512
/home/epronk/gnocchi/trunk/gcov_reader.cpp:251: mccabe=29 npath=20194
/home/epronk/gnocchi/trunk/gcov_reader.cpp:251: mccabe=29 npath=20194
This is compiler style output pointing out which functions have a high
complexity. By default it outputs all functions with a NPATH
complexity higher than 200.
C++ EXCEPTIONS
For every function call, GCC inserts extra paths which are used when
an exception occurs. This "experimental" measure is now part of the
output.
mccabe=5(+4) means the complexity is 5 + 4 = 9 if exceptions are considered.
./gnocchi -t 1 test_input.gcno
test_input.c:10: mccabe=2 npath=2
test_input.c:19: mccabe=2(+1) npath=2(+1)
test_input.c:28: mccabe=2 npath=2
test_input.c:40: mccabe=4 npath=4
test_input.c:145: mccabe=3 npath=4
test_input.c:159: mccabe=3 npath=4
test_input.c:118: mccabe=5 npath=5
test_input.c:89: mccabe=5(+4) npath=16(+15)
test_input.c:67: mccabe=9 npath=80
GETTING GNOCCHI
Get a release from:
http://sourceforge.net/project/showfiles.php?group_id=197216
or get the latest sources from
svn co https://gnocchi.svn.sourceforge.net/svnroot/gnocchi gnocchi
RUNNING GNOCCHI
./configure
make
gcc -fprofile-arcs -ftest-coverage -c test_input.c
./gnocchi --threshold 4 test_input.gcno
outputs:
test_input.c:118: mccabe=5 npath=5
test_input.c:89: mccabe=5 npath=16
test_input.c:67: mccabe=9 npath=80
ACKNOWLEDGEMENTS
I wrote Gnocchi after seeing a demo of Complexian for Java. [4]
Thanks to Marty Andrews for his presentation about complexity at MXPEG.
REFERENCES
[1] T.J. McCabe, "A complexity measure," IEEE Trans.
Software Eng. vol. SE2, no 4, pp 308-320, 1976
[2] B.A. Nejmeh, "NPATH: a measure of execution path complexity and its applications,"
Commun, ACM, vol 31, no 2, pp 188-200, 1988.
[3] http://en.wikipedia.org/wiki/Cyclomatic_complexity
[4] Complexity Analyser for Java,
http://www.martyandrews.net/resources/complexian.html
http://www.cogentconsulting.com.au/products/index.html
Any feedback can be sent to Eddy Pronk <epronk@muftor.com>
---
Gnocchi is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Gnocchi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
--