129 lines
4.6 KiB
HTML
129 lines
4.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
|
|
<!--Converted with LaTeX2HTML 99.1 release (March 30, 1999)
|
|
original version by: Nikos Drakos, CBLU, University of Leeds
|
|
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
|
|
* with significant contributions from:
|
|
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>4.7 Cyclomatic Complexity</TITLE>
|
|
<META NAME="description" CONTENT="4.7 Cyclomatic Complexity">
|
|
<META NAME="keywords" CONTENT="sdccman">
|
|
<META NAME="resource-type" CONTENT="document">
|
|
<META NAME="distribution" CONTENT="global">
|
|
|
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
|
<META NAME="Generator" CONTENT="LaTeX2HTML v99.1 release">
|
|
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
|
|
|
<LINK REL="STYLESHEET" HREF="sdccman.css">
|
|
|
|
<LINK REL="previous" HREF="node44.html">
|
|
<LINK REL="up" HREF="node38.html">
|
|
<LINK REL="next" HREF="node46.html">
|
|
</HEAD>
|
|
|
|
<BODY >
|
|
<!--Navigation Panel-->
|
|
<A NAME="tex2html937"
|
|
HREF="node46.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
|
|
<A NAME="tex2html931"
|
|
HREF="node38.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
|
|
<A NAME="tex2html927"
|
|
HREF="node44.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
|
|
<A NAME="tex2html933"
|
|
HREF="node1.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
|
|
<A NAME="tex2html935"
|
|
HREF="node61.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html938"
|
|
HREF="node46.html">5. TIPS</A>
|
|
<B> Up:</B> <A NAME="tex2html932"
|
|
HREF="node38.html">4. SDCC Technical Data</A>
|
|
<B> Previous:</B> <A NAME="tex2html928"
|
|
HREF="node44.html">4.6 ANSI-Compliance</A>
|
|
  <B> <A NAME="tex2html934"
|
|
HREF="node1.html">Contents</A></B>
|
|
  <B> <A NAME="tex2html936"
|
|
HREF="node61.html">Index</A></B>
|
|
<BR>
|
|
<BR>
|
|
<!--End of Navigation Panel-->
|
|
|
|
<H2><A NAME="SECTION00057000000000000000">
|
|
4.7 Cyclomatic Complexity</A>
|
|
</H2>
|
|
|
|
<P>
|
|
Cyclomatic complexity of a function is defined as the number of independent
|
|
paths the program can take during execution of the function. This
|
|
is an important number since it defines the number test cases you
|
|
have to generate to validate the function. The accepted industry standard
|
|
for complexity number is 10, if the cyclomatic complexity reported
|
|
by SDCC exceeds 10 you should think about simplification of the function
|
|
logic. Note that the complexity level is not related to the number
|
|
of lines of code in a function. Large functions can have low complexity,
|
|
and small functions can have large complexity levels.
|
|
<BR>
|
|
|
|
<BR>
|
|
SDCC uses the following formula to compute the complexity:
|
|
<BR>
|
|
|
|
<P>
|
|
complexity = (number of edges in control flow graph) - (number of
|
|
nodes in control flow graph) + 2;
|
|
<BR>
|
|
|
|
<BR>
|
|
Having said that the industry standard is 10, you should be aware
|
|
that in some cases it be may unavoidable to have a complexity level
|
|
of less than 10. For example if you have switch statement with more
|
|
than 10 case labels, each case label adds one to the complexity level.
|
|
The complexity level is by no means an absolute measure of the algorithmic
|
|
complexity of the function, it does however provide a good starting
|
|
point for which functions you might look at for further optimization.
|
|
|
|
<P>
|
|
<HR>
|
|
<!--Navigation Panel-->
|
|
<A NAME="tex2html937"
|
|
HREF="node46.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next_motif.gif"></A>
|
|
<A NAME="tex2html931"
|
|
HREF="node38.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up_motif.gif"></A>
|
|
<A NAME="tex2html927"
|
|
HREF="node44.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="previous_motif.gif"></A>
|
|
<A NAME="tex2html933"
|
|
HREF="node1.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents_motif.gif"></A>
|
|
<A NAME="tex2html935"
|
|
HREF="node61.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index_motif.gif"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html938"
|
|
HREF="node46.html">5. TIPS</A>
|
|
<B> Up:</B> <A NAME="tex2html932"
|
|
HREF="node38.html">4. SDCC Technical Data</A>
|
|
<B> Previous:</B> <A NAME="tex2html928"
|
|
HREF="node44.html">4.6 ANSI-Compliance</A>
|
|
  <B> <A NAME="tex2html934"
|
|
HREF="node1.html">Contents</A></B>
|
|
  <B> <A NAME="tex2html936"
|
|
HREF="node61.html">Index</A></B>
|
|
<!--End of Navigation Panel-->
|
|
<ADDRESS>
|
|
<I>Johan Knol</I>
|
|
<BR><I>2001-07-13</I>
|
|
</ADDRESS>
|
|
</BODY>
|
|
</HTML>
|