最近做一些批次化的改造,需要預估團隊整體工作量。因爲按業務本身複雜度來統計需要熟悉所有程式碼,執行上很難操作,因此用程式碼行數來評估工作量
研究了幾種工具和方法
pip install line-counter
,以goredis目錄爲例子wjcdeMacBook-Pro-2:redis wujingci$ line
Search in /Users/wujingci/go/src/github.com/go-redis/redis/
file count: 68
line count: 17776
wjcdeMacBook-Pro-2:redis wujingci$ line -d
Search in /Users/wujingci/go/src/github.com/go-redis/redis/
LICENSE 25
Makefile 20
README.md 143
bench_test.go 220
cluster.go 1439
cluster_commands.go 22
cluster_test.go 880
command.go 1048
command_test.go 60
commands.go 2175
commands_test.go 3290
doc.go 4
缺點在於只能統計總檔案,肯定會有一些組態檔,會導致估算不準 不準確
xxxMacBook-Pro-2:redis wujingci$ git ls-files| xargs cloc
70 text files.
70 unique files.
3 files ignored.
github.com/AlDanial/cloc v 1.85 T=0.14 s (466.1 files/s, 123562.4 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Go 64 2899 594 14085
Markdown 1 31 0 112
YAML 1 4 0 16
make 1 5 0 15
-------------------------------------------------------------------------------
SUM: 67 2939 594 14228
-------------------------------------------------------------------------------
這個方法可以較快統計出內容甚至把程式語言也給明確了。缺點在於統計不夠定製化。比如go服務引入了govendor,那實際有效程式碼行數很有可能被誤統計進去
find . -name "*.go"|xargs cat|grep -v -e ^$ -e ^\s*\/\/.*$|wc -l
find . -name "*.go| grep -v vendor"|xargs cat|grep -v -e ^$ -e ^\s*\/\/.*$|wc -l