代码统计

http://exp99.diandian.com/post/2012-06-02/40028807537

使用工具 cloc 

cloc (Count Lines Of Code) counts, and computes differences of, comment lines, blank lines, and physical lines of source code in many programming languages.

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.

使用方法:

http://garfileo.is-programmer.com/2010/6/11/lines-counting-using-cloc.18828.html

使用 cloc 统计代码行数

Garfileo posted @ 2010年6月11日 18:32 in  业余程序猿的足迹 with tags  cloc  代码行数统计 , 4350 阅读

可能大家都知道用 `wc -l` 命令进行代码行数统计,但是它会将代码中的注释、空行所占用的文本行都统计在内。如果想查看一个 tar 包或一个项目目录中“实际”的代码行数并且不愿意自己去写一个脚本来做此类工作,那么可以考虑使用 cloc

cloc 是一个 perl 脚本,它可以统计很多种编程语言的代码文件中的空行、注释以及实际的代 码行数。

示例 1:统计一个 tar 包中的代码行

$ > cloc small-2.0.tar.gz 
      42 text files.
      41 unique files.                              
       4 files ignored.

http://cloc.sourceforge.net v 1.50  T=1.0 s (38.0 files/s, 3451.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               21            435            482           1695
C/C++ Header                     8            102            161            275
m4                               4             18              4            136
make                             4             18             72             29
Bourne Shell                     1              2             20              2
-------------------------------------------------------------------------------
SUM:                            38            575            739           2137
-------------------------------------------------------------------------------

示例 2:统计项目目录中的代码行数

$> cd m2boxtree
$> cloc ./
      68 text files.
      65 unique files.                              
      23 files ignored.

http://cloc.sourceforge.net v 1.50  T=0.5 s (88.0 files/s, 9258.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               17            611             94           2490
C/C++ Header                    14            230            301            381
Bourne Shell                    10             56            155            252
make                             2              3              0             25
Python                           1              4              4             23
-------------------------------------------------------------------------------
SUM:                            44            904            554           3171
-------------------------------------------------------------------------------
安装方法:

先安装brew

http://blog.csdn.net/jijunyuan/article/details/39672291

安装命令如下:
curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1
当brew安装成功后,就可以随意安装自己想要的软件了,例如cloc,命令如下:
sudo brew install cloc


卸载的话,命令如下:

sudo brew uninstall cloc

查看安装软件的话,命令如下:

sudo brew search /apache*/                    /apache*/是使用的正则表达式,用/分割。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值