Hi all,
So, I investigated the discrepancies between the hand count / LOCC and
SCLC. It turns out that all the source (non-comment) lines of code
counts match exactly between the tools. However, there is an
algorithmic difference between how LOCC (and myself) and SCLC count
comment lines of code.
Essentially, if a line contains source code followed by an end-of-line
comment, LOCC treats this as a source line of code. If the line is
entirely a comment (either multiline or single line), it treats it as a
comment line of code. This way, if you add up the SLOC and CLOC
measurements, you will get the sum of all lines without whitespace in
the file.
On the other hand, when SCLC encounters a line of source code followed
by an end-of-line comment, it increments both the SLOC and CLOC counts.
This also seems reasonable, but there is certainly some overlap in the
total of the two measurements.
The files affected are as follows (all measurements are for comment
lines of code - CLOC):
matrix_multiply.c: LOCC = 18, SCLC = 25
pi_calc.c: LOCC = 31, SCLC = 41
theta_logistic.m: handcount = 18, SCLC = 38
What's most important is that the source lines of code (SLOC)
measurements are the same for both tools, but we should decide how to
deal with the comment lines.
Have a good night all.
Best regards,
Mike
(Cedric) Qin ZHANG wrote:
Hi,
(1) I have imported the module hackySCLC. The build.xml is a dummy.
There are lots of trouble writing ant script invoking OS command.
However, I have supplied demo.sh to do the same thing build.xml is
supposed to do. Or you can invoke sclc yourself.
(2) Mike's testing files are imported as well. However, there is
discrepancy between mike's count and sclc count.
Below is the original sclc output. Attached is the hacked sclc xml
output.
Cheers,
Cedric
C:\work\hackySCLC\lib\examples>perl sclc1.pl -recurse .
Lines Blank Cmnts NCSL
===== ===== ===== =====
==================================================
36 4 13 19 .\markov.m (Matlab)
54 4 25 32 .\matrix_multiply.c (C)
56 9 18 29 .\matrix_multiply.f (FORTRAN)
88 11 41 46 .\pi_calc.c (C)
99 18 46 35 .\pi_calc.f (FORTRAN)
1955 164 801 1024 .\sclc1.pl (Perl)
443 80 28 335 .\T02_Inner.java (Java)
230 20 91 119 .\test.java (Java)
54 7 19 28 .\TestStack.java (Java)
56 9 38 29 .\theta_logistic.m (Matlab)
1955 164 801 1024 ----- Perl ----- (1 file)
142 15 66 78 ----- C ----- (2 files)
155 27 64 64 ----- FORTRAN ----- (2 files)
92 13 51 48 ----- Matlab ----- (2 files)
727 107 138 482 ----- Java ----- (3 files)
3071 326 1120 1696 ***** TOTAL ***** (10 files)
Mike Paulding wrote:
Hi Cedric,
I have attached some sample test files for use with SCLC. There are
two files for each of the four "starter" languages: C, Java, Fortran
and Matlab. I handcounted each of them and ran LOCC over the Java
and C files (some were test cases in the LOCC module).
Here is a summary of the files for each language. Note that each
file contains the source lines of code (SLOC, code without comments)
and comment lines of code (CLOC) metrics within them.
************
JAVA
************
TestStack.java - SLOC = 28, CLOC = 19
T02_Inner.java - SLOC = 335, CLOC = 28
************
C/C++
************
matrix_multiply.c - SLOC = 32, CLOC = 18
pi_calc.c - SLOC = 46, CLOC = 31
************
FORTRAN
************
matrix_multiply.f - SLOC = 29, CLOC = 18
pi_calc.f - SLOC = 35, CLOC = 46
************
MATLAB
************
markov.m - SLOC = 19, CLOC = 13
theta_logistic.m - SLOC = 29, CLOC = 18
Please let me know if there are any discrepancies between the hand
and LOCC count and that produced by SCLC.
Best regards,
Mike
Philip Johnson wrote:
Hi Cedric,
Great start! To facilitate development and evaluation of this
system, could you please do the following:
* import a new CVS module called hackySCLC
* create a src/ directory containing your version of sclc.pl
* create a lib/examples directory containing files of example code
in a variety of languages. Relatively short files of Java, C, C++,
Matlab, and Fortran would do for starters. Mike, can you help supply
Cedric with some sample code ASAP?
* create a build.xml file. For starters, the default target should
simply invoke the sclc.pl program on the example code, putting the
resulting XML in the build/ directory. Later, we can augment this
into a testing framework (save "correct" versions of the XML files,
run the sclc version, and compare the output to the oracle versions,
etc.)
* create a README.html file that gives pointers to installation of
PERL and any required libraries.
Once this is done, it will be easy for all of us to see the XML that
is generated by different languages, contribute new example code to
see what happens, and simplify testing and evolution. Please let us
know when this is available so we can check it out!
Cheers,
Philip
--On Thursday, August 18, 2005 1:43 AM -1000 "Qin ZHANG (Cedric)"
<[EMAIL PROTECTED]> wrote:
Hi,
I hacked the original script and now it outputs xml instead of plain
text. Usage is still the same. Please notice that this is just a
proof-of-concept hack, not the final product.
Please try it and let me know what needs to be improved. At this
stage, I
am more interested in user requirements, such as what should
command line
option be and what should the xml output be.
The script uses perl XML::DOM library. If you are on a recent linux
distribution, you should be ok. If you are on windows using active
state
perl, you need to download the libary from www.cpan.org yourself.
Thanks.
Cedric
------------------------------------------------------------------------
<?xml version="1.0"?>
<sclc>
<file lines="443" blank="80" cmnts="28" ncsl="335" aesl="2010"
fname="lib/examples/T02_Inner.java" language="Java"/>
<file lines="54" blank="7" cmnts="19" ncsl="28" aesl="168"
fname="lib/examples/TestStack.java" language="Java"/>
<file lines="36" blank="4" cmnts="13" ncsl="19" aesl="285" fname="lib/examples/markov.m"
language="Matlab"/>
<file lines="54" blank="4" cmnts="25" ncsl="32" aesl="80"
fname="lib/examples/matrix_multiply.c" language="C"/>
<file lines="56" blank="9" cmnts="18" ncsl="29" aesl="145"
fname="lib/examples/matrix_multiply.f" language="FORTRAN"/>
<file lines="88" blank="11" cmnts="41" ncsl="46" aesl="115" fname="lib/examples/pi_calc.c"
language="C"/>
<file lines="99" blank="18" cmnts="46" ncsl="35" aesl="175" fname="lib/examples/pi_calc.f"
language="FORTRAN"/>
<file lines="230" blank="20" cmnts="91" ncsl="119" aesl="714" fname="lib/examples/test.java"
language="Java"/>
<file lines="1955" blank="164" cmnts="801" ncsl="1024" aesl="15360"
fname="lib/examples/test.pl" language="Perl"/>
<file lines="56" blank="9" cmnts="38" ncsl="29" aesl="435"
fname="lib/examples/theta_logistic.m" language="Matlab"/>
</sclc>