#!/bin/bash
# 检查 traces 目录下所有 trace 文件是否能得到100分
TRACE_DIR="traces"
PERFECT_LIST="PERFECT_TRACES.txt"

# 清空 PERFECT_LIST.txt
> "$PERFECT_LIST"

# 遍历所有 .rep 文件
for trace in "$TRACE_DIR"/*.rep; do
    echo "Testing $trace..."
    # 运行 malloc 并捕获输出
    output=$(./malloc -f "$trace" 2>&1)
    
    # 检查输出中是否包含 "Performance index = 100"
    if echo "$output" | grep -q "100/100" ; then
        echo "Perfect score found for $(basename "$trace")"
        echo "$(basename "$trace")" >> "$PERFECT_LIST"
    fi
done

echo "Updated $PERFECT_LIST with traces that achieved perfect scores." 