统计两个版本之间代码变更行数

使用工具diffcount可以统计一个项目之间两个版本的代码变动量。新版本较老版本有多少新增、修改、删除、有效代码量等。

工具/原料

  • diffcount
  • 两个差异代码版本

方法/步骤

  1. 解压diffcount压缩包,将其放在C盘。

  2. 在C:\diffcount\diffcount\test下建立两个文件夹,old,new.

  3. 将需要比较的未改动之前版本的代码分别复制到两个文件夹。

  4. 使用改动完成的代码将new文件夹中的代码覆盖,得到两个差异版本。

    统计两个版本之间代码变更行数
  5. 打开cmd窗口,输入"cd c:\diffcount\diffcount"进入diffcount.exe文件夹。

    统计两个版本之间代码变更行数
  6. 输入 "diffcount test\old test\new --print-files-info > result.txt"将比较结果输出到“C:\diffcount\diffcount\result.txt”

    (注:如果文件较多执行时间较长)

    统计两个版本之间代码变更行数
  7. 执行完毕后得到比较结果文件,可使用excel默认分隔设定打开。也可以使用其它文本编辑器打开。

    LANG:语言或配置文件类型

    ADD:新增代码行数

    MOD:修改代码行数

    DEL:删除代码行数

    A&M:新增与修改代码行数之和

    BLK:空行数

    CMT:注释行数

    NBNC:非空非注释行数

    RATE:标准C折算率

    统计两个版本之间代码变更行数
  8. 帮助

    C:\diffcount\diffcount>diffcount.exe --help

    Usage: diffcount.exe [OPTION]... (Baseline) Target

    Compare and diff two packages or only couting one code package

    OPTIONS:

       -c --count-only

           Only counting one code package

       --ignore-case

           Ignore the difference of file name case

       --print-lines-info

           Print detailed information of every diffed lines

           Slow, Debug use only

       --print-files-info

           Print every diffed file result information.

       --force-parse-all

           Parsing all diffed files(default: skip same file)

       --for-program-reading

          Change result output style for Third-party program reading

          Will disable --print-lines-info automaticly

       -v  --version

           Output current version.

       --help

           Show this page

        --cn-help

          Show Chinese help page

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
通过例子介绍使用方法如下: 1.差异统计 统计某一个版本代码包相对于一个原始的基线代码包,变动的代码量 以及变动的代码量中各语言非空非注释(NBNC)的结果 缺省执的就是差异统计,直接跟上两个代码包的目录即可 实际使用中,可能会有文件名和目录名大小写不一致的情况,如果希望忽略 文件名大小写的差异,需要使用 --ignore-case 参数,否则两个一样的文件 一个会算作删除,一个会算作新增 Diffcount [test\sp1] and [test\sp2] result: LANG ADD MOD DEL A&M BLK CMT NBNC RATE ----------------------------------------------------------------------- C 44 7 26 51 8 11 35 1.00 Pascal 0 0 25 0 0 0 0 0.23 Java 7 4 11 11 0 3 9 0.41 Config 31 4 0 35 1 0 34 0.12 XML 126 0 0 126 2 0 124 0.12 ----------------------------------------------------------------------- Convert all NBNC lines to standard C Total: 57.65 (standard C lines) ADD MOD DEL A&M BLK CMT NBNC RATE 的 含义分别为: 新增、修改、删除、新增+修改、空、注释、非空非注释、标准C折算率 2.代码统计: 如果需要,可以把diffcount当作普通的代码统计工具,统计一个代码代码统计使用 -c (或者--count-only)参数, 在diffcount目录下执结果如下: Counting package [test\count] result: LANG TOTAL BLK CMT NBNC RATE ----------------------------------------------------------------------- C 203 46 61 101 1.00 C++ 57 7 25 25 0.42 Pascal 117 24 17 79 0.23 Java 71 7 24 40 0.41 ASM 129 34 12 85 2.50 C# 18 1 1 17 0.20 Basic 447 140 20 295 0.21 Perl 97 4 26 74 0.16 TCL/TK 91 12 26 54 0.50 Config 116 13 0 103 0.12 XML 126 2 0 124 0.12 ----------------------------------------------------------------------- Convert all NBNC lines to standard C Total: 490.00 (standard C lines) 如果想显示每一个文件的具体信息,请使用 --print-files-info 参数

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值