开发者
资源
文档评分
获取效率
正确性
完整性
易理解
在线提单
论坛求助

diff对比命令

命令功能

支持对多次采集生成的JSON文件进行性能数据对比,并输出终端报告和Excel报告。

命令格式

1
./ksys diff [-h] -i INPUT INPUT [-o OUTPUT] [-l {0,1,2,3}]

参数说明

表1 参数说明

参数

参数选项

参数说明

-h/--help

-

可选参数,获取帮助信息。

-i/--input

-

必选参数,指定两个JSON文件的路径,该JSON文件必须是使用collect命令采集得到的,文件之间用空格隔开。

例如:

-i /home/test/2025_08_14_15_17_25_report.json /home/test/2025_08_14_16_11_28_report.json
说明:

鲲鹏性能定界工具支持采集系统、应用或进程性能数据,不同类型生成的JSON文件不能进行对比。

-o/--output

-

可选参数,指定对比结果存放目录,不指定则在当前目录下生成格式为“Y_M_D_H_M_S_diff.xlsx”的Excel文件。

-l/--log-level

0/1/2/3

可选参数,设置日志级别,默认为1。

  • 0:日志级别为DEBUG。
  • 1:日志级别为INFO。
  • 2:日志级别为WARNING。
  • 3:日志级别为ERROR。

使用示例

  1. 执行以下命令,查看diff命令支持的功能信息:
    1
    ./ksys diff -h
    
    返回信息如下:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    USAGE
        ksys diff [-h] -i INPUT INPUT [-o OUTPUT] [-l {0,1,2,3}]
    
    DESCRIPTION
        Create a compare command line task.
    
    options:
        -h, --help
        show this help message and exit
    
        -i INPUT INPUT, --input INPUT INPUT
        Input two JSON file's paths. These files must be collected by running the collect command.
        In the report, the first input file's data locates under the header 'Before', and the
        second input file's data locates under the header 'After'.
    
        -o OUTPUT, --output OUTPUT
        Output the full path.
    
        -l {0,1,2,3}, --log-level {0,1,2,3}
        Set the log level (0=DEBUG, 1=INFO, 2=WARNING, 3=ERROR), which defaults to 1(INFO).
    
  2. 执行对比命令对比采集前后的性能差异,并生成对比报告。
    ./ksys diff -i /home/test/2026_06_18_09_17_37_report.json /home/test/2026_06_18_09_19_48_report.json -o /home/test

    返回信息以鲲鹏920新型号处理器的服务器为例:

    ========================================================================System Info========================================================================
    System Architecture diff:
    +--------------+-------------------------------+-------------------------------+------+
    |    Metric    |             Before            |             After             | Diff |
    +--------------+-------------------------------+-------------------------------+------+
    | Cpu Type     | Kunpeng920 high-performance   | Kunpeng920 high-performance   | N/A  |
    | Model Name   | HUAWEI Kunpeng 920 V200 7270Z | HUAWEI Kunpeng 920 V200 7270Z | N/A  |
    | Vendor ID    | HiSilicon                     | HiSilicon                     | N/A  |
    | Hyper Thread | False                         | False                         | N/A  |
    | CPU-NUM      |                           256 |                           256 | N/A  |
    +--------------+-------------------------------+-------------------------------+------+
    
    ========================================================================CPU Metrics========================================================================
    Common Microarchitecture Metrics diff:
    +--------------+-------------+-------------+-----------+
    |    Metric    |    Before   |    After    |    Diff   |
    +--------------+-------------+-------------+-----------+
    | IPC          |        0.36 |        0.35 | -2.78%    |
    | MPKI         |        0.17 |        8.28 | +4770.59% |
    | BPKI         |        0.52 |        0.57 | +9.62%    |
    | L1D MPKI     |         1.5 |        5.44 | +262.67%  |
    | L1I MPKI     |        1.03 |        1.01 | -1.94%    |
    | L2D MPKI     |        1.15 |        19.7 | +1613.04% |
    | L2I MPKI     |        0.17 |        0.24 | +41.18%   |
    | DTLB MPKI    |        2.81 |        3.49 | +24.20%   |
    | INSTRUCTIONS | 49500897138 | 57874938856 | +16.92%   |
    | ITLB MPKI    |        0.38 |        0.24 | -36.84%   |
    +--------------+-------------+-------------+-----------+
    
    Topdown diff:
    +----------------------------+--------+-------+---------+
    |           Metric           | Before | After |   Diff  |
    +----------------------------+--------+-------+---------+
    | Retiring(%)                |   5.62 |  5.74 | +2.14%  |
    | Frontend Bound(%)          |   5.43 |  7.13 | +31.31% |
    |   Fetch Bandwidth Bound(%) |   0.65 |   1.1 | +69.23% |
    |   Fetch Latency Bound(%)   |   4.78 |  6.03 | +26.15% |
    | Bad Speculation(%)         |   0.14 |  0.15 | +7.14%  |
    |   Branch Mispredicts(%)    |    0.1 |   0.1 | +0.00%  |
    |   Machine Clears(%)        |   0.04 |  0.05 | +25.00% |
    | Backend Bound(%)           |  88.81 | 86.98 | -2.06%  |
    |   Core Bound(%)            |   39.8 |  37.9 | -4.77%  |
    |   Memory Bound(%)          |  49.01 | 49.08 | +0.14%  |
    +----------------------------+--------+-------+---------+
    
    OS Metrics diff:
    +------------------+--------+-------+---------+
    |      Metric      | Before | After |   Diff  |
    +------------------+--------+-------+---------+
    | context-switches |  90400 | 85002 | -5.97%  |
    | migrations       |    326 |   338 | +3.68%  |
    | page-faults      |   7356 | 11278 | +53.32% |
    +------------------+--------+-------+---------+
    
    INSTRUCTION diff:
    +----------------------------------+--------+-------+---------+
    |              Metric              | Before | After |   Diff  |
    +----------------------------------+--------+-------+---------+
    | Memory(%)                        |  25.18 | 31.94 | +26.85% |
    |   Load(%)                        |  25.18 | 31.94 | +26.85% |
    |   Store(%)                       |    0.0 |   0.0 | +0.00%  |
    | Scalar(%):                       |  51.36 | 43.49 | -15.32% |
    |   Integer(%)                     |  51.33 | 43.46 | -15.33% |
    |   Floating Point(%)              |   0.03 |  0.03 | +0.00%  |
    | Vector(%)                        |   0.04 |  0.03 | -25.00% |
    |   Advanced SIMD(%)               |   0.04 |  0.03 | -25.00% |
    |   SVE(+loads/stores)(%):         |    0.0 |   0.0 | +0.00%  |
    |   SME(retired)(%):               |    0.0 |   0.0 | +0.00%  |
    |     Integer(%)                   |    0.0 |   0.0 | +0.00%  |
    |     Floating Point(%)            |    0.0 |   0.0 | +0.00%  |
    | Crypto(%)                        |    0.0 |   0.0 | +0.00%  |
    | Branches(%)                      |  21.33 | 21.92 | +2.77%  |
    |   Immediate(%)                   |  20.04 | 20.17 | +0.65%  |
    |   Return(%)                      |   0.56 |  0.79 | +41.07% |
    |   Indirect(%)                    |   0.73 |  0.96 | +31.51% |
    | Barriers(%)                      |   0.05 |  0.08 | +60.00% |
    |   Instruction Synchronization(%) |   0.01 |  0.01 | +0.00%  |
    |   Data Synchronization(%)        |    0.0 |   0.0 | +0.00%  |
    |   Data Memory(%)                 |   0.04 |  0.07 | +75.00% |
    | Not Retired(%)                   |   2.04 |  2.54 | +24.51% |
    +----------------------------------+--------+-------+---------+
    ...
    Net_info Network Device veth0b2fba5 diff:
    +----------+--------+-------+---------+
    |  Metric  | Before | After |   Diff  |
    +----------+--------+-------+---------+
    | rxpck/s  |   2.25 |  1.25 | -44.44% |
    | txpck/s  |   2.25 |  1.25 | -44.44% |
    | rxkB/s   |   0.18 |  0.12 | -33.33% |
    | txkB/s   |   0.18 |  0.08 | -55.56% |
    | rxcmp/s  |    0.0 |   0.0 | +0.00%  |
    | txcmp/s  |    0.0 |   0.0 | +0.00%  |
    | rxmcst/s |    0.0 |   0.0 | +0.00%  |
    | %ifutil  |    0.0 |   0.0 | +0.00%  |
    +----------+--------+-------+---------+
    
    ==========================================================================Top diff=========================================================================
    Top diff:
    -----------------------------------------------------------------------------------------------------------------------------
    Note:
        At most 20 Top diffs are listed. Only metrics with more than 50% change are displayed.
        Please check the generated xlsx file for the full report.
    
    +-------------+----------------------------------+-----------------------+----------+------------+------------+-------------+
    | Table Group |    Metric Type/Metric Device     |         Metric        |  Before  |   After    |    Diff    | Diff(value) |
    +-------------+----------------------------------+-----------------------+----------+------------+------------+-------------+
    | HHA         | HHA DEVICE hisi_sccl9_hha0       | rx_outer              | 116492.0 | 16066810.4 | +13692.20% |  15950318.4 |
    | HHA         | HHA DEVICE hisi_sccl9_hha0       | rx_ops_num            | 718658.8 | 16629768.0 | +2214.00%  |  15911109.2 |
    | HHA         | HHA DEVICE hisi_sccl11_hha0      | rx_outer              | 118290.4 | 15999106.0 | +13425.28% |  15880815.6 |
    | HHA         | HHA DEVICE hisi_sccl9_hha2       | rx_outer              | 112178.8 | 15976764.0 | +14142.23% |  15864585.2 |
    | HHA         | HHA DEVICE hisi_sccl11_hha0      | rx_ops_num            | 699687.2 | 16560295.2 | +2266.81%  |  15860608.0 |
    | PA          | PA hisi_sicl2_pa0                | PA2Ring MB/s          |   107.17 |   12036.89 | +11131.59% |    11929.72 |
    | PA          | PA hisi_sicl2_pa0                | PA2Ring_lk1 MB/s      |   103.81 |    8715.15 | +8295.29%  |     8611.34 |
    | PA          | PA hisi_sicl10_pa0               | Ring2PA MB/s          |   114.73 |     8716.6 | +7497.49%  |     8601.87 |
    | PA          | PA hisi_sicl10_pa0               | Ring2PA_lk0 MB/s      |    64.69 |     6191.7 | +9471.34%  |     6127.01 |
    | PA          | PA hisi_sicl10_pa0               | PA2Ring MB/s          |    90.39 |    3515.77 | +3789.56%  |     3425.38 |
    | DDRC        | DDRC summary                     | Total ddrc_rd_bw MB/s |   206.92 |    7897.81 | +3716.84%  |     7690.89 |
    | DDRC        | DDRC summary                     | Total ddrc_wr_bw MB/s |   204.37 |     627.46 | +207.02%   |      423.09 |
    | OS          | OS Metrics                       | page-faults           |     7356 |      11278 | +53.32%    |        3922 |
    | IO_info     | IO_info Summary                  | Total wkB/s           |  2683.58 |       37.0 | -98.62%    |     2646.58 |
    | IO_info     | IO_info IO Device dm-0           | wkB/s                 |   899.86 |       13.0 | -98.56%    |      886.86 |
    | IO_info     | IO_info IO Device sdb            | wkB/s                 |   891.86 |       12.0 | -98.65%    |      879.86 |
    | IO_info     | IO_info IO Device sdb3           | wkB/s                 |   891.86 |       12.0 | -98.65%    |      879.86 |
    | IO_info     | IO_info Summary                  | Total tps             |     89.5 |        4.5 | -94.97%    |        85.0 |
    | CPU_stat    | CPU_stat                         | soft_interrupts/s     |   1066.0 |     2156.0 | +102.25%   |      1090.0 |
    | Common      | Common Microarchitecture Metrics | L2D MPKI              |     1.15 |       19.7 | +1613.04%  |       18.55 |
    +-------------+----------------------------------+-----------------------+----------+------------+------------+-------------+
    
    Data has been saved to /home/test/2026_06_18_09_44_26_diff.xlsx

    对比后的数据保存在“/home/test/2026_06_18_09_44_26_diff.xlsx”文件中。对比分析会比较两次采集的Summary数据,并在最后生成Top diff报告,通过Top diff看出第二次采集后的性能开销较大。