首页 > 代码库 > CLOC(Count Lines Of Code)代码统计工具
CLOC(Count Lines Of Code)代码统计工具
cloc 是一个 perl 脚本,它可以统计很多种编程语言的代码文件中的空行、注释以及实际的代码行数。
相关网站:
http://cloc.sourceforge.net/
http://sourceforge.jp/projects/sfnet_cloc/releases/
安装
环境 windows 7 + Vmware Player 6.0 + fedora 18(linux 3.6.10) + gcc 4.7.2
Linux环境下:
[root@localhost ~]# yum install cloc
Loaded plugins: langpacks, presto, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package cloc.noarch 0:1.60-1.fc18 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
cloc noarch 1.60-1.fc18 updates 78 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 78 k
Installed size: 343 k
Is this ok [y/N]: y
Downloading Packages:
cloc-1.60-1.fc18.noarch.rpm | 78 kB 00:05
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : cloc-1.60-1.fc18.noarch 1/1
Verifying : cloc-1.60-1.fc18.noarch 1/1
Installed:
cloc.noarch 0:1.60-1.fc18
Complete!
按照默认统计
[root@localhost ~]# cloc /usr/src/kernels/3.6.10-4.fc18.i686/
Digest::MD5 not installed; will skip file uniqueness checks.
6119 text files.
5233 unique files.
4975 files ignored.
http://cloc.sourceforge.net v 1.60 T=109.92 s (38.0 files/s, 6195.0 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
C/C++ Header 3234 76738 147946 364503
C 54 4392 3446 26102
make 818 5155 4947 21123
Perl 20 1626 1629 8943
ASP.Net 1 212 0 5327
Bourne Shell 33 444 719 2156
C++ 1 208 57 1524
yacc 3 215 82 1291
lex 3 146 80 764
NAnt scripts 1 96 0 382
Python 2 55 64 230
Bourne Again Shell 2 36 16 221
Assembly 1 3 0 42
--------------------------------------------------------------------------------
SUM: 4173 89326 158986 432608
--------------------------------------------------------------------------------
按照文件统计
[root@localhost include]# cloc -by-file acpi
Digest::MD5 not installed; will skip file uniqueness checks.
27 text files.
27 unique files.
0 files ignored.
http://cloc.sourceforge.net v 1.60 T=0.36 s (75.6 files/s, 23255.7 lines/s)
-------------------------------------------------------------------------------------
File blank comment code
-------------------------------------------------------------------------------------
acpi/actbl1.h 171 225 567
acpi/actbl2.h 173 308 567
acpi/actypes.h 213 388 525
acpi/acrestyp.h 114 111 379
acpi/acpixf.h 120 102 344
acpi/acpi_bus.h 63 56 335
acpi/processor.h 44 21 290
acpi/actbl3.h 107 168 277
acpi/acexcep.h 24 65 212
acpi/actbl.h 48 136 196
acpi/platform/acenv.h 63 169 148
acpi/acoutput.h 43 115 129
acpi/acpiosxf.h 67 97 117
acpi/platform/aclinux.h 29 65 86
acpi/acpi_drivers.h 23 55 79
acpi/acconfig.h 62 129 57
acpi/apei.h 10 3 33
acpi/acnames.h 11 44 30
acpi/pdc_intel.h 7 1 27
acpi/video.h 7 0 27
acpi/button.h 3 0 22
acpi/acpi_numa.h 4 1 16
acpi/acpi.h 4 50 12
acpi/platform/acgcc.h 9 52 10
acpi/container.h 3 0 9
acpi/reboot.h 3 0 8
acpi/hed.h 4 8 6
-------------------------------------------------------------------------------------
SUM: 1429 2369 4508
-------------------------------------------------------------------------------------
CLOC(Count Lines Of Code)代码统计工具