diff --git a/count_asm.sh b/count_asm.sh old mode 100644 new mode 100755 index e698e97d..e44d51ce --- a/count_asm.sh +++ b/count_asm.sh @@ -23,28 +23,23 @@ TESTS=( "03_sort1" "03_sort2" "03_sort3" "01_mm1" "01_mm2" "01_mm3" ) - BASELINE_FILE="./指令数基线.md" +TMP_ASM="./.count_tmp.s" UPDATED=0 - echo "=== 指令数测试 ===" for t in "${TESTS[@]}"; do - $COMPILER -S -O -o /tmp/count_tmp.s 2026test/performance/${t}.sy 2>/dev/null - lines=$(wc -l < /tmp/count_tmp.s 2>/dev/null) + $COMPILER -S -O -o "$TMP_ASM" 2026test/performance/${t}.sy 2>/dev/null + lines=$(wc -l < "$TMP_ASM" 2>/dev/null) lines=${lines:-0} - - # 读取基线值 - baseline=$(grep "performance/${t}" "$BASELINE_FILE" 2>/dev/null | grep -oP '\|\s*\d+\s*\|' | head -1 | grep -oP '\d+') - if [[ -n "$baseline" ]] && [[ "$baseline" =~ ^[0-9]+$ ]]; then + baseline=$(grep "performance/${t}" "$BASELINE_FILE" 2>/dev/null | grep -oP '\|\s*\d+\s*\|' | grep -oP '\d+') + if [[ -n "$baseline" && "$baseline" =~ ^[0-9]+$ ]]; then if [[ "$lines" -lt "$baseline" ]]; then diff=$((baseline - lines)) - echo "performance/${t}: ${lines} (基线:${baseline} 减少${diff}行) ← 更新基线" - # 更新基线文件中的"当前"列(匹配任意当前值) - sed -i "s/| performance\/${t} | ${baseline} | [0-9]* |/| performance\/${t} | ${baseline} | ${lines} | 比源基线少${diff}行 |/" "$BASELINE_FILE" + echo "performance/${t}: ${lines} (基线:${baseline} 减少${diff}行) <- 更新基线" + sed -i "s/| performance\/${t} | ${baseline} |/| performance\/${t} | ${lines} |/" "$BASELINE_FILE" UPDATED=$((UPDATED + 1)) elif [[ "$lines" -gt "$baseline" ]]; then - diff=$((lines - baseline)) - echo "performance/${t}: ${lines} (基线:${baseline} 增加${diff}行)" + echo "performance/${t}: ${lines} (基线:${baseline} 增加$((lines - baseline))行)" else echo "performance/${t}: ${lines} (基线:${baseline} 持平)" fi @@ -52,8 +47,7 @@ for t in "${TESTS[@]}"; do echo "performance/${t}: ${lines}" fi done -rm -f /tmp/count_tmp.s - +rm -f "$TMP_ASM" if [[ $UPDATED -gt 0 ]]; then echo "" echo "已更新 ${UPDATED} 个测试集的指令数基线" diff --git a/指令数基线.md b/指令数基线.md index c54e7eb7..37066c6c 100644 --- a/指令数基线.md +++ b/指令数基线.md @@ -2,85 +2,84 @@ ## 更新规则 -1. 本文件手动维护,记录性能测试集的汇编指令行数 -2. 源基线:首次测量时的指令数,永不更改 -3. 当前:最新编译器版本的指令数 -4. 仅更新性能测试集(performance/)的指令数 -5. 若指令数减少,更新"当前"列并在"备注"标注比源基线减少的数量 +1. 本文件自动维护(count_asm.sh),记录性能测试集的汇编指令行数 +2. 基线 = 历史最低指令数,当且仅当新测量值更低时更新 +3. 仅更新性能测试集(performance/)的指令数 +4. 若新指令数 < 基线,直接更新为更小的值 ## 报告信息 | 项目 | 值 | |---|---| -| 生成时间 | 2026-05-21 | +| 生成时间 | 2026-05-24 | | 编译器优化 | true | | 计数方式 | 编译器 -S -O 生成的汇编文件行数 | | 说明 | 指令数减少 = 编译器改进,不受 QEMU 测量噪声影响 | ## 测试结果 -| 测试集标识 | 源基线(行) | 当前(行) | 备注 | -|---|---|---|---| -| performance/01_mm1 | 335 | 310 | 比源基线少25行 | 比源基线少25行 | 比源基线少25行 | 比源基线少22行 | 比源基线少22行 | 比源基线少8行 | | -| performance/01_mm2 | 335 | 310 | 比源基线少25行 | 比源基线少25行 | 比源基线少25行 | 比源基线少22行 | 比源基线少22行 | 比源基线少8行 | | -| performance/01_mm3 | 335 | 310 | 比源基线少25行 | 比源基线少25行 | 比源基线少25行 | 比源基线少22行 | 比源基线少22行 | 比源基线少8行 | | -| performance/03_sort1 | 668 | 640 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少14行 | | -| performance/03_sort2 | 668 | 640 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少14行 | | -| performance/03_sort3 | 668 | 640 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少28行 | 比源基线少14行 | | -| performance/conv2d-1 | 752 | 629 | 比源基线少123行 | 比源基线少123行 | 比源基线少123行 | 比源基线少95行 | 比源基线少95行 | 比源基线少20行 | | -| performance/conv2d-2 | 752 | 629 | 比源基线少123行 | 比源基线少123行 | 比源基线少123行 | 比源基线少95行 | 比源基线少95行 | 比源基线少20行 | | -| performance/conv2d-3 | 752 | 629 | 比源基线少123行 | 比源基线少123行 | 比源基线少123行 | 比源基线少95行 | 比源基线少95行 | 比源基线少20行 | | -| performance/crc1 | 328 | 290 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少10行 | | -| performance/crc2 | 328 | 290 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少10行 | | -| performance/crc3 | 328 | 290 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少38行 | 比源基线少10行 | | -| performance/crypto-1 | 1967 | 1949 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少14行 | | -| performance/crypto-2 | 1967 | 1949 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少14行 | | -| performance/crypto-3 | 1967 | 1949 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少14行 | | -| performance/fft0 | 658 | 605 | 比源基线少53行 | 比源基线少53行 | 比源基线少53行 | 比源基线少39行 | 比源基线少39行 | 比源基线少30行 | | -| performance/fft1 | 658 | 605 | 比源基线少53行 | 比源基线少53行 | 比源基线少53行 | 比源基线少39行 | 比源基线少39行 | 比源基线少30行 | | -| performance/fft2 | 658 | 605 | 比源基线少53行 | 比源基线少53行 | 比源基线少53行 | 比源基线少39行 | 比源基线少39行 | 比源基线少30行 | | -| performance/h-1-01 | 162 | 158 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少2行 | | -| performance/h-1-02 | 162 | 158 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少2行 | | -| performance/h-1-03 | 162 | 158 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少4行 | 比源基线少2行 | | -| performance/h-10-01 | 349 | 329 | 比源基线少20行 | 比源基线少20行 | 比源基线少20行 | 比源基线少14行 | 比源基线少14行 | 比源基线少6行 | | -| performance/h-10-02 | 349 | 329 | 比源基线少20行 | 比源基线少20行 | 比源基线少20行 | 比源基线少14行 | 比源基线少14行 | 比源基线少6行 | | -| performance/h-10-03 | 349 | 329 | 比源基线少20行 | 比源基线少20行 | 比源基线少20行 | 比源基线少14行 | 比源基线少14行 | 比源基线少6行 | | -| performance/h-4-01 | 173 | 163 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少6行 | | -| performance/h-4-02 | 173 | 163 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少6行 | | -| performance/h-4-03 | 173 | 163 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | 比源基线少6行 | | -| performance/h-5-01 | 352 | 349 | 比源基线少3行 | 比源基线少3行 | 比源基线少10行 | | -| performance/h-5-02 | 352 | 349 | 比源基线少3行 | 比源基线少3行 | 比源基线少10行 | | -| performance/h-5-03 | 352 | 349 | 比源基线少3行 | 比源基线少3行 | 比源基线少10行 | | -| performance/h-8-01 | 504 | 407 | 比源基线少97行 | 比源基线少97行 | 比源基线少2行 | 比源基线少2行 | 比源基线少2行 | 比源基线少2行 | | -| performance/h-8-02 | 504 | 407 | 比源基线少97行 | 比源基线少97行 | 比源基线少2行 | 比源基线少2行 | 比源基线少2行 | 比源基线少2行 | | -| performance/h-8-03 | 504 | 407 | 比源基线少97行 | 比源基线少97行 | 比源基线少2行 | 比源基线少2行 | 比源基线少2行 | 比源基线少2行 | | -| performance/h-9-01 | 239 | 227 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少2行 | | -| performance/h-9-02 | 239 | 227 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少2行 | | -| performance/h-9-03 | 239 | 227 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少12行 | 比源基线少2行 | | -| performance/huffman-01 | 893 | 829 | 比源基线少64行 | 比源基线少64行 | 比源基线少64行 | 比源基线少44行 | 比源基线少44行 | 比源基线少14行 | | -| performance/huffman-02 | 893 | 829 | 比源基线少64行 | 比源基线少64行 | 比源基线少64行 | 比源基线少44行 | 比源基线少44行 | 比源基线少14行 | | -| performance/huffman-03 | 893 | 829 | 比源基线少64行 | 比源基线少64行 | 比源基线少64行 | 比源基线少44行 | 比源基线少44行 | 比源基线少14行 | | -| performance/knapsack_naive-1 | 185 | 167 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | | -| performance/knapsack_naive-2 | 185 | 167 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | | -| performance/knapsack_naive-3 | 185 | 167 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少10行 | 比源基线少10行 | 比源基线少10行 | | -| performance/many_mat_cal-1 | 523 | 432 | 比源基线少91行 | 比源基线少91行 | | -| performance/many_mat_cal-2 | 523 | 432 | 比源基线少91行 | 比源基线少91行 | | -| performance/many_mat_cal-3 | 523 | 432 | 比源基线少91行 | 比源基线少91行 | | -| performance/matmul1 | 450 | 366 | 比源基线少84行 | 比源基线少84行 | | -| performance/matmul2 | 450 | 366 | 比源基线少84行 | 比源基线少84行 | | -| performance/matmul3 | 450 | 366 | 比源基线少84行 | 比源基线少84行 | | -| performance/optimization_scheduling1 | 136 | 122 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少6行 | | -| performance/optimization_scheduling2 | 136 | 122 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少6行 | | -| performance/optimization_scheduling3 | 136 | 122 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少14行 | 比源基线少6行 | | -| performance/shuffle0 | 485 | 472 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少6行 | | -| performance/shuffle1 | 485 | 472 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少6行 | | -| performance/shuffle2 | 485 | 472 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少13行 | 比源基线少6行 | | -| performance/sl1 | 283 | 264 | 比源基线少19行 | 比源基线少19行 | 比源基线少19行 | 比源基线少3行 | 比源基线少3行 | 比源基线少8行 | | -| performance/sl2 | 283 | 264 | 比源基线少19行 | 比源基线少19行 | 比源基线少19行 | 比源基线少3行 | 比源基线少3行 | 比源基线少8行 | | -| performance/sl3 | 283 | 264 | 比源基线少19行 | 比源基线少19行 | 比源基线少19行 | 比源基线少3行 | 比源基线少3行 | 比源基线少8行 | | -| performance/transpose0 | 225 | 207 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少14行 | 比源基线少14行 | 比源基线少4行 | | -| performance/transpose1 | 225 | 207 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少14行 | 比源基线少14行 | 比源基线少4行 | | -| performance/transpose2 | 225 | 207 | 比源基线少18行 | 比源基线少18行 | 比源基线少18行 | 比源基线少14行 | 比源基线少14行 | 比源基线少4行 | | +| 测试集标识 | 基线(行) | +|---|---| +| performance/01_mm1 | 310 | +| performance/01_mm2 | 310 | +| performance/01_mm3 | 310 | +| performance/03_sort1 | 640 | +| performance/03_sort2 | 640 | +| performance/03_sort3 | 640 | +| performance/conv2d-1 | 629 | +| performance/conv2d-2 | 629 | +| performance/conv2d-3 | 629 | +| performance/crc1 | 290 | +| performance/crc2 | 290 | +| performance/crc3 | 290 | +| performance/crypto-1 | 1949 | +| performance/crypto-2 | 1949 | +| performance/crypto-3 | 1949 | +| performance/fft0 | 605 | +| performance/fft1 | 605 | +| performance/fft2 | 605 | +| performance/h-1-01 | 158 | +| performance/h-1-02 | 158 | +| performance/h-1-03 | 158 | +| performance/h-10-01 | 329 | +| performance/h-10-02 | 329 | +| performance/h-10-03 | 329 | +| performance/h-4-01 | 163 | +| performance/h-4-02 | 163 | +| performance/h-4-03 | 163 | +| performance/h-5-01 | 352 | +| performance/h-5-02 | 352 | +| performance/h-5-03 | 352 | +| performance/h-8-01 | 407 | +| performance/h-8-02 | 407 | +| performance/h-8-03 | 407 | +| performance/h-9-01 | 227 | +| performance/h-9-02 | 227 | +| performance/h-9-03 | 227 | +| performance/huffman-01 | 829 | +| performance/huffman-02 | 829 | +| performance/huffman-03 | 829 | +| performance/knapsack_naive-1 | 167 | +| performance/knapsack_naive-2 | 167 | +| performance/knapsack_naive-3 | 167 | +| performance/many_mat_cal-1 | 432 | +| performance/many_mat_cal-2 | 432 | +| performance/many_mat_cal-3 | 432 | +| performance/matmul1 | 366 | +| performance/matmul2 | 366 | +| performance/matmul3 | 366 | +| performance/optimization_scheduling1 | 122 | +| performance/optimization_scheduling2 | 122 | +| performance/optimization_scheduling3 | 122 | +| performance/shuffle0 | 472 | +| performance/shuffle1 | 472 | +| performance/shuffle2 | 472 | +| performance/sl1 | 264 | +| performance/sl2 | 264 | +| performance/sl3 | 264 | +| performance/transpose0 | 207 | +| performance/transpose1 | 207 | +| performance/transpose2 | 207 | ## 统计