fix up simple example
[fw/sdcc] / doc / sdccman.html / node45.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
3 <!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
4 original version by:  Nikos Drakos, CBLU, University of Leeds
5 * revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
6 * with significant contributions from:
7   Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
8 <HTML>
9 <HEAD>
10 <TITLE>4.7 Cyclomatic Complexity</TITLE>
11 <META NAME="description" CONTENT="4.7 Cyclomatic Complexity">
12 <META NAME="keywords" CONTENT="sdccman">
13 <META NAME="resource-type" CONTENT="document">
14 <META NAME="distribution" CONTENT="global">
15
16 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
17 <META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
18 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
19
20 <LINK REL="STYLESHEET" HREF="sdccman.css">
21
22 <LINK REL="previous" HREF="node44.html">
23 <LINK REL="up" HREF="node38.html">
24 <LINK REL="next" HREF="node46.html">
25 </HEAD>
26
27 <BODY >
28 <!--Navigation Panel-->
29 <A NAME="tex2html937"
30  HREF="node46.html">
31 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
32 <A NAME="tex2html931"
33  HREF="node38.html">
34 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
35 <A NAME="tex2html927"
36  HREF="node44.html">
37 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
38 <A NAME="tex2html933"
39  HREF="node1.html">
40 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
41 <A NAME="tex2html935"
42  HREF="node61.html">
43 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
44 <BR>
45 <B> Next:</B> <A NAME="tex2html938"
46  HREF="node46.html">5. TIPS</A>
47 <B> Up:</B> <A NAME="tex2html932"
48  HREF="node38.html">4. SDCC Technical Data</A>
49 <B> Previous:</B> <A NAME="tex2html928"
50  HREF="node44.html">4.6 ANSI-Compliance</A>
51  &nbsp <B>  <A NAME="tex2html934"
52  HREF="node1.html">Contents</A></B> 
53  &nbsp <B>  <A NAME="tex2html936"
54  HREF="node61.html">Index</A></B> 
55 <BR>
56 <BR>
57 <!--End of Navigation Panel-->
58
59 <H2><A NAME="SECTION00057000000000000000">
60 4.7 Cyclomatic Complexity</A>
61 </H2>
62
63 <P>
64 Cyclomatic complexity of a function is defined as the number of independent
65 paths the program can take during execution of the function. This
66 is an important number since it defines the number test cases you
67 have to generate to validate the function. The accepted industry standard
68 for complexity number is 10, if the cyclomatic complexity reported
69 by SDCC exceeds 10 you should think about simplification of the function
70 logic. Note that the complexity level is not related to the number
71 of lines of code in a function. Large functions can have low complexity,
72 and small functions can have large complexity levels. 
73 <BR>
74
75 <BR>
76 SDCC uses the following formula to compute the complexity:
77 <BR>
78
79 <P>
80 complexity = (number of edges in control flow graph) - (number of
81 nodes in control flow graph) + 2;
82 <BR>
83
84 <BR>
85 Having said that the industry standard is 10, you should be aware
86 that in some cases it be may unavoidable to have a complexity level
87 of less than 10. For example if you have switch statement with more
88 than 10 case labels, each case label adds one to the complexity level.
89 The complexity level is by no means an absolute measure of the algorithmic
90 complexity of the function, it does however provide a good starting
91 point for which functions you might look at for further optimization.
92
93 <P>
94 <HR>
95 <!--Navigation Panel-->
96 <A NAME="tex2html937"
97  HREF="node46.html">
98 <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A> 
99 <A NAME="tex2html931"
100  HREF="node38.html">
101 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A> 
102 <A NAME="tex2html927"
103  HREF="node44.html">
104 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A> 
105 <A NAME="tex2html933"
106  HREF="node1.html">
107 <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A> 
108 <A NAME="tex2html935"
109  HREF="node61.html">
110 <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A> 
111 <BR>
112 <B> Next:</B> <A NAME="tex2html938"
113  HREF="node46.html">5. TIPS</A>
114 <B> Up:</B> <A NAME="tex2html932"
115  HREF="node38.html">4. SDCC Technical Data</A>
116 <B> Previous:</B> <A NAME="tex2html928"
117  HREF="node44.html">4.6 ANSI-Compliance</A>
118  &nbsp <B>  <A NAME="tex2html934"
119  HREF="node1.html">Contents</A></B> 
120  &nbsp <B>  <A NAME="tex2html936"
121  HREF="node61.html">Index</A></B> 
122 <!--End of Navigation Panel-->
123 <ADDRESS>
124 <I>Johan Knol</I>
125 <BR><I>2001-07-13</I>
126 </ADDRESS>
127 </BODY>
128 </HTML>