代码统计开源工具 SLOCCount

Posted offduty

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了代码统计开源工具 SLOCCount相关的知识,希望对你有一定的参考价值。

1 简介

SLOC(Source Lines of Code),是一套用于统计项目中用到的多种源代码总行数的工具。此外,SLOC 还会估算出开发该项目所需的工作量、所需人员和时间等项目成本(基于 COCOMO 模型)。目前 SLOC 支持的语言多达 27 种。

  1. Ada (.ada, .ads, .adb)
  2. Assembly (.s, .S, .asm)
  3. awk (.awk)
  4. Bourne shell and variants (.sh)
  5. C (.c)
  6. C++ (.C, .cpp, .cxx, .cc)
  7. C shell (.csh)
  8. COBOL (.cob, .cbl) as of version 2.10
  9. C# (.cs) as of version 2.11
  10. Expect (.exp)
  11. Fortran (.f)
  12. Haskell (.hs) as of version 2.11
  13. Java (.java)
  14. lex/flex (.l)
  15. LISP/Scheme (.el, .scm, .lsp, .jl)
  16. Makefile (makefile) - not normally shown.
  17. Modula-3 (.m3, .i3) as of version 2.07
  18. Objective-C (.m)
  19. Pascal (.p, .pas)
  20. Perl (.pl, .pm, .perl)
  21. php (.php, .php[3456], .inc) as of version 2.05
  22. Python (.py)
  23. Ruby (.rb) as of version 2.09
  24. sed (.sed)
  25. SQL (.sql) - not normally shown.
  26. TCL (.tcl, .tk, .itk)
  27. 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

以上是关于代码统计开源工具 SLOCCount的主要内容,如果未能解决你的问题,请参考以下文章

开源海看源代码统计工具 Haikan Source Code Counter

分享一个开源的JavaScript统计图表库,40行代码实现专业统计图表

主流源代码管理工具—GitHub

源代码管理工具GitHub介绍

源代码管理工具GitHub介绍

c_cpp 快速代码片段,用于在统计(阻止)/ dev / rdsk中的设备时验证fstat64和stat64的行为。