代码统计
来源:互联网 发布:北京朝阳有线网络电视 编辑:程序博客网 时间:2024/05/01 10:06
http://www.cfanz.cn/?c=article&a=read&id=48713
http://exp99.diandian.com/post/2012-06-02/40028807537
因项目汇报,需要统计代码规模。
自然的想法是用Shell来统计各种文件(.php|js|css|html|xml|yaml)的代码规模
> find . -name "*.php" -exec grep -Ev "^$" {} \;|wc -l75450> find . -name "*.js" -exec grep -Ev "^$" {} \;|wc -l 36725> find . -name "*.html" -exec grep -Ev "^$" {} \;|wc -l 17830> find . -name "*.css" -exec grep -Ev "^$" {} \;|wc -l 4146> find . -name "*.xml" -exec grep -Ev "^$" {} \;|wc -l 4349> find . -name "*.yaml" -exec grep -Ev "^$" {} \;|wc -l 0
在sourceforge发现统计代码规模的好工具 cloc.pl。
引用下官方的简介
cloc counts blank lines, comment lines, and physical lines of source code in many
programming languages. Given two versions of a code base, cloc can compute differences
in blank, comment, and source lines. It is written entirely in Perl with no dependencies
outside the standard distribution of Perl v5.6 and higher (code from some external modules
is embedded within cloc) and so is quite portable. cloc is known to run on many flavors of
Linux, Mac OS X, AIX, Solaris, IRIX, z/OS, and Windows. (To run the Perl source version of
cloc on Windows one needs ActiveState Perl 5.6.1 or higher, Cygwin, or MobaXTerm with the
Perl plug-in installed. Alternatively one can use the Windows binary of cloc generated with
perl2exe to run on Windows computers that have neither Perl nor Cygwin.)
接下来介绍下如何使用cloc.pl来统计代码规模:
1).下载脚本
> wget http://nchc.dl.sourceforge.net/project/cloc/cloc/v1.56/cloc-1.56.pl
2).给脚本添加执行权限+x
> chmod +x cloc-1.56.pl
3).对项目源码打开
> tar zcvf itravel2.tar.gz itravel2
4).统计代码规模
> ./cloc-1.56.pl itravel2.tar.gz 595 text files. 594 unique files. 2507 files ignored. http://cloc.sourceforge.net v 1.56 T=4.0 s (148.0 files/s, 35279.8 lines/s)-------------------------------------------------------------------------------Language files blank comment code-------------------------------------------------------------------------------PHP 224 4018 9848 62685Javascript 118 3570 3083 31469HTML 215 574 2557 14820XML 19 0 57 4292CSS 16 160 473 3513-------------------------------------------------------------------------------SUM: 592 8322 16018 116779-------------------------------------------------------------------------------
欲知关于cloc.pl脚本详细的信息,请参见 http://cloc.sourceforge.net/
- 代码统计
- 代码统计
- 代码统计
- 代码统计
- 统计代码行数代码
- 网站流量统计代码
- 代码行数统计类
- 网站流量统计代码
- 网站流量统计代码
- 代码行数统计器
- 统计代码行数源码
- 登陆用户统计代码!
- 统计代码行数
- 统计代码行数源码
- 网站流量统计代码
- 代码行数统计工具
- 网站流量统计代码
- 代码行数统计器
- MVC3 Razor模板引擎 @RenderBody、@RenderPage、@RenderSection
- 【eXtremeComponents总结系列】使用总结(不定期更新中)
- uC/OS-II 学习笔记之:实时操作系统
- 在Hibernate中创建安全Session
- java for循环的几种写法
- 代码统计
- uC/OS-II 学习笔记之:任务的优先级别和任务数
- ant编译程序提示非法字符: \65279
- SQL Sever 2008 R2安装指南
- showmount: can't get address for localhost
- Rigidbody.ClosestPointOnBounds 到边界框的最近点
- Linux ALSA声卡驱动之六:ASoC架构中的Machine
- 树莓派运行PHP脚本
- 如何诊断Windows CE的应用程序崩溃