File size: 1,340 Bytes
f0f4f2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import sys


def count_success_files(test_result, target_llm, target_project, lang_pair):
    directory = os.path.join(test_result, target_llm, target_project, lang_pair)
    success_count = 0
    total_count = 0
    for filename in os.listdir(directory):
        file_path = os.path.join(directory, filename)
        
        if os.path.isfile(file_path):
            total_count += 1

            with open(file_path, 'r') as file:
                content = file.read().strip()
                if content.startswith("Success"):
                    success_count += 1



    return total_count, success_count

test_result = sys.argv[1]
target_llm = sys.argv[2]
llms = os.listdir(test_result)
for llm in llms:
    if target_llm not in llm:
        continue
    target_projects = os.listdir(os.path.join(test_result, llm))
    llm_success_count = 0
    llm_total_count = 0
    for target_project in target_projects:
        lang_pairs = os.listdir(os.path.join(test_result, llm, target_project))
        for lang_pair in lang_pairs:
            total_count, success_count = count_success_files(test_result, llm, target_project, lang_pair)
            llm_success_count += success_count
            llm_total_count += total_count

    print(f"{target_llm}'s pass@1 on RustRepoTrans is {float(llm_success_count) / llm_total_count}")