SLOC ?

Source lines of code (SLOC) is a software metric used to measure the amount of code in a software program. SLOC is typically used to estimate the amount of effort that will be required to develop a program, as well as to estimate productivity or effort once the software is produced.

Measuring SLOC

There are two major types of SLOC measures: physical SLOC and logical SLOC. Specific definitions of these two measures vary, but the most common definition of physical SLOC is a count of "non-blank, non-comment lines" in the text of the program's source code. Logical SLOC measures attempt to measure the number of "statements", but their specific definitions are tied to specific computer languages (one simple logical SLOC measure for C-like languages is the number of statement-terminating semicolons). It is much easier to create tools that measure physical SLOC, and physical SLOC definitions are easier to explain. However, physical SLOC measures are sensitive to logically irrelevant formatting and style conventions, while logical SLOC is less sensitive to formatting and style conventions. Unfortunately, SLOC measures are often stated without giving their definition, and logical SLOC can often be significantly different from physical SLOC.

Consider this snippet of C code as an example of the ambiguity encountered when determining SLOC:
~cpp
for (i=0; i<100; ++i) printf("hello"); /* How many lines of code is this? */
Depending on the programmer and/or coding standards, the above "line of code" could be, and usually is, written on many separate lines:


~cpp
for (i=0; i<100; ++i)
{
    printf("hello");
} /* Now how many lines of code is this? */
Even the "logical" and "physical" SLOC values can have a large number of varying definitions. Robert E. Park (while at the Software Engineering Institute) et al. developed a framework for defining SLOC values, to enable people to carefully explain and define the SLOC measure used in a project. For example, most software systems reuse code, and determining which (if any) reused code to include is important when reporting a measure.

Counting Program

http://www.dwheeler.com/sloccount/

제로페이지 서버내에 이 프로그램이 설치되어있습니다.
프로젝트의 진행이나 PL 숙제를 할 때 사용하도록 하셔요~ - 관리자

How to count

텍스트 형태의 출력
~cpp
root@zeropage# sloccount --wide --multiproject . > result.txt

HTML 형태 출력
http://www.dwheeler.com/sloccount/sloc2html.py
http://www.dwheeler.com/sloccount/sloc2html-example.html 참조
~cpp
sloccount --wide --multiproject . > result.txt
sloc2html.py result.txt

example of actual project

Result of network packet analyzer 2006 by eternalbleu
~cpp
      1 Creating filelist for pl
      2 Categorizing files.
      3 Finding a working MD5 command....
      4 Found a working MD5 command.
      5 Computing results.
      6 
      7 
      8 SLOC    Directory   SLOC-by-Language (Sorted)
      9 3101    pl              cpp=3101
     10 
     11 
     12 Totals grouped by language (dominant language first):
     13 cpp:           3101 (100.00%)
     14 
     15 
     16 
     17 
     18 Total Physical Source Lines of Code (SLOC)                = 3,101
     19 Development Effort Estimate, Person-Years (Person-Months) = 0.66 (7.88)
     20  (Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
     21 Schedule Estimate, Years (Months)                         = 0.46 (5.48)
     22  (Basic COCOMO model, Months = 2.5 * (person-months**0.38))
     23 Estimated Average Number of Developers (Effort/Schedule)  = 1.44
     24 Total Estimated Cost to Develop                           = $ 88,658
     25  (average salary = $56,286/year, overhead = 2.40).
     26 SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
     27 SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
     28 SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
     29 redistribute it under certain conditions as specified by the GNU GPL license;
     30 see the documentation for details.
     31 Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
이 프로그램의 계산에 의해면 나는 이 프로젝트로 개발에 대충 88 불정도가 소모되는 프로그램을 만들었다 ㅡ.ㅡ;;;; MFC의 도움인가 ㅋㅋㅋ
자기가 짜논 프로그램가지고 돌려 보333 엄청 잼있네 이 프로그램 ㅡ,.ㅡ
밤새도록 파이선 UI 코드 짯는데 190라인 떳다 ㅜ.ㅜ 제기~~ - eternalbleu
Retrieved from http://wiki.zeropage.org/wiki.php/Source_lines_of_code
last modified 2021-02-07 05:28:05