`
newleague
  • 浏览: 1477716 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

代码统计工具COLC

阅读更多
虽说代码行数不重要,但有时候总想统计下自己的代码行数,看看最近的成果。以前一直用这个国产小软件,但感觉操作稍显烦琐,我更喜欢命令行的方式,自由度更高。昨天无意中在这里发现了叫做CLOC的小软件,基于Perl,并且是Opensource的,地址是http://cloc.sourceforge.net/。下载后只有一个cloc.exe文件,使用方式也很简单,只需要:cloc.exe /path/to/source-code,输出如下:

Java代码 复制代码
  1. C:\Documents and Settings\kenny>cloc D:\Projects\myproject\   
  2.      900 text files.   
  3. classified 900 files   
  4.      634 unique files.   
  5.      607 files ignored.   
  6.   
  7. http://cloc.sourceforge.net v 1.04  T=3.0 s (84.3 files/s, 11367.0 lines/s)   
  8. -------------------------------------------------------------------------------   
  9. Language          files     blank   comment      code    scale   3rd gen. equiv   
  10. -------------------------------------------------------------------------------   
  11. Java                135      1778      1963      8779 x   1.36 =       11939.44  
  12. Javascript           22      1875      1761      8590 x   1.48 =       12713.20  
  13. XML                  39       308       247      2744 x   1.90 =        5213.60  
  14. HTML                 39        33       474      2000 x   1.90 =        3800.00  
  15. CSS                  11       156        72      1445 x   1.00 =        1445.00  
  16. DTD                   1       234       254       713 x   1.90 =        1354.70  
  17. SQL                   2        42        44       406 x   2.29 =         929.74  
  18. JSP                   3        18        14       106 x   1.48 =         156.88  
  19. XSLT                  1         0         6        39 x   1.90 =          74.10  
  20. -------------------------------------------------------------------------------   
  21. SUM:                253      4444      4835     24822 x   1.52 =       37626.66  
  22. -------------------------------------------------------------------------------  
C:\Documents and Settings\kenny>cloc D:\Projects\myproject\
     900 text files.
classified 900 files
     634 unique files.
     607 files ignored.

http://cloc.sourceforge.net v 1.04  T=3.0 s (84.3 files/s, 11367.0 lines/s)
-------------------------------------------------------------------------------
Language          files     blank   comment      code    scale   3rd gen. equiv
-------------------------------------------------------------------------------
Java                135      1778      1963      8779 x   1.36 =       11939.44
Javascript           22      1875      1761      8590 x   1.48 =       12713.20
XML                  39       308       247      2744 x   1.90 =        5213.60
HTML                 39        33       474      2000 x   1.90 =        3800.00
CSS                  11       156        72      1445 x   1.00 =        1445.00
DTD                   1       234       254       713 x   1.90 =        1354.70
SQL                   2        42        44       406 x   2.29 =         929.74
JSP                   3        18        14       106 x   1.48 =         156.88
XSLT                  1         0         6        39 x   1.90 =          74.10
-------------------------------------------------------------------------------
SUM:                253      4444      4835     24822 x   1.52 =       37626.66
-------------------------------------------------------------------------------

当然了,有很多选项可以用,具体的可以看看cloc首页的介绍。当然,每次这样手动输入命令很麻烦,考虑下和Total-Commander结合。编辑一个cloc.bat文件,内容如下:
引用
cloc.exe %1
PAUSE

把这个bat文件拖到TC的工具栏上

然后在工具栏新出现的图标上点右键,选“更改”,然后把参数设置为%p,如图:

“确定”后大功告成,在TC里进入你的源码目录时,点击刚才新建的图标,就开始自动统计当前目录了。
下载地址: http://sourceforge.net/project/showfiles.php?group_id=174787
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics