项目代码统计

项目代码统计:

工具一:SourceInsight

工程建立完毕后,选择菜单Project->Project Report ,再选择需要的选项导出报表,点ok。

比如,我选择每个文件的大小以及行数。

结果如下:

使用source insight工具统计代码的确比较方便,一键即可完成,但有一定的局限性,比如不能对文件按照类型进行统计。

工具二:Linux命令行

#查看代码文件列表
find
. -name '*.c' -o -name '*.h' -o -name '*.html' -o -name '*.htm' -o -name '*.txt' -o -name 'Makefile' -o -name '*.pl' > ~/code.file #统计代码文件数 find . -name '*.c' -o -name '*.h' -o -name '*.html' -o -name '*.htm' -o -name '*.txt' -o -name 'Makefile' -o -name '*.pl' | wc -l >> ~/code.file
#统计代码总行数
find . -regex ".*(.h|.c|.htm|.html|.pl|.txt|Makefile)$" | xargs wc -l

使用linux命令的好处是搜索速度很快,而且后续还可以将命令整理后,输出一个脚本,实现自动化统计。

原文地址:https://www.cnblogs.com/BinBinStory/p/7635245.html