1 简介
SLOC(Source Lines of Code),是一套用于统计项目中用到的多种源代码总行数的工具。此外,SLOC 还会估算出开发该项目所需的工作量、所需人员和时间等项目成本(基于 COCOMO 模型)。目前 SLOC 支持的语言多达 27 种。
- Ada (.ada, .ads, .adb)
- Assembly (.s, .S, .asm)
- awk (.awk)
- Bourne shell and variants (.sh)
- C (.c)
- C++ (.C, .cpp, .cxx, .cc)
- C shell (.csh)
- COBOL (.cob, .cbl) as of version 2.10
- C# (.cs) as of version 2.11
- Expect (.exp)
- Fortran (.f)
- Haskell (.hs) as of version 2.11
- Java (.java)
- lex/flex (.l)
- LISP/Scheme (.el, .scm, .lsp, .jl)
- Makefile (makefile) - not normally shown.
- Modula-3 (.m3, .i3) as of version 2.07
- Objective-C (.m)
- Pascal (.p, .pas)
- Perl (.pl, .pm, .perl)
- PHP (.php, .php[3456], .inc) as of version 2.05
- Python (.py)
- Ruby (.rb) as of version 2.09
- sed (.sed)
- SQL (.sql) - not normally shown.
- TCL (.tcl, .tk, .itk)
- Yacc/Bison (.y)
2 安装
- 源码安装: tar.gz
- RPM 包安装: rpm 包
sudo rpm -ivh sloccount-2.26-1.i386.rpm
- Debian:
sudo apt-get install sloccount
3 用法
语法:sloccount directory_name
示例(以 tensorflow 源码为例)
$ sloccount tensorflow-master
...
SLOC Directory SLOC-by-Language (Sorted)
1929666 tensorflow cpp=1313054,python=571706,java=15935,ansic=10758,
pascal=8380,sh=8343,objc=1172,cs=168,perl=150
75546 third_party cpp=72614,python=2799,sh=96,lisp=37
1016 top_dir python=1008,sh=8
130 tools sh=130
Totals grouped by language (dominant language first):
cpp: 1385668 (69.06%)
python: 575513 (28.68%)
java: 15935 (0.79%)
ansic: 10758 (0.54%)
sh: 8577 (0.43%)
pascal: 8380 (0.42%)
objc: 1172 (0.06%)
cs: 168 (0.01%)
perl: 150 (0.01%)
lisp: 37 (0.00%)
Total Physical Source Lines of Code (SLOC) = 2,006,358
Development Effort Estimate, Person-Years (Person-Months) = 586.89 (7,042.71)
(Basic COCOMO model, Person-Months = 2.4 * (KSLOC**1.05))
Schedule Estimate, Years (Months) = 6.04 (72.46)
(Basic COCOMO model, Months = 2.5 * (person-months**0.38))
Estimated Average Number of Developers (Effort/Schedule) = 97.20
Total Estimated Cost to Develop = $ 79,281,247
(average salary = $56,286/year, overhead = 2.40).
SLOCCount, Copyright (C) 2001-2004 David A. Wheeler
SLOCCount is Open Source Software/Free Software, licensed under the GNU GPL.
SLOCCount comes with ABSOLUTELY NO WARRANTY, and you are welcome to
redistribute it under certain conditions as specified by the GNU GPL license;
see the documentation for details.
Please credit this data as "generated using David A. Wheeler's 'SLOCCount'."
参考资料:
https://dwheeler.com/sloccount/sloccount.html
原文地址:https://www.cnblogs.com/offduty/p/11736400.html
时间: 2024-10-15 16:45:08