Ejemplo n.º 1
0
def report_c1_t1_mx_sub(root_dir, config_name, test_name, metric_name):
    global result_title
    global result_table
    global first_p
    result_dir = root_dir + "result/" + test_name + "/"
    driver.sure_to_exist(result_dir)
    db_fn = config_name + "--" + test_name + "--" + metric_name + ".json"
    db_filename = result_dir + db_fn
    if verbose_p:
        print("use " + db_filename)
    json_data = load_json_file(db_filename)
    title = get_title(json_data)
    if title[0] != 'TITLE':
        driver.data_error('report_c1_t1_mx_sub 0')
    bar = title[1]
    if first_p:
        result_title.extend(bar)
    else:
        result_title.extend(bar[3:])
    data_size = len(bar) - 1
    index = 0
    for row in json_data[1:]:
        bb = row[0]
        data = row[1]
        if len(data) != data_size:
            driver.data_error('report_c1_t1_mx_sub 1')
        if first_p:
            data.insert(0, bb)
            result_table.append(data)
        else:
            result_table[index].extend(data[2:])
        index += 1
    first_p = False
Ejemplo n.º 2
0
def find_mark(list, start_index):
    index = start_index
    while True:
        if list[index] == -1:
            return index
        index += 1
    driver.data_error('find_mark')
Ejemplo n.º 3
0
def pad_data(bar, data, part_global_title):
    fix_data = []
    g_size = len(part_global_title)
    size = len(bar)
    bar_index = 0
    g_index = 0
    while bar_index < size:
        x = bar[bar_index]
        d = data[bar_index]
        bar_index += 1
        while True:
            g = part_global_title[g_index]
            g_index += 1
            if x == g:
                fix_data.append(d)
                break
            else:
                fix_data.append('')
    while g_index < g_size:
        g = part_global_title[g_index]
        fix_data.append('')
        g_index += 1
    if len(fix_data) != len(part_global_title):
        print(fix_data)
        print(part_global_title)
        driver.data_error('pad_data')
    return fix_data
Ejemplo n.º 4
0
def read_perf_result_file(filename):
    if not os.path.exists(filename):
        driver.data_error("file not found: `" + filename + "'")
    perf_data = None
    with open(filename, 'rt') as fin:
        perf_data = read_perf_result_file_sub(fin)
    return perf_data
Ejemplo n.º 5
0
def get_bb_list(target_config, filename, function_name):
    bb_list = None
    if not os.path.exists(filename):
        driver.data_error("file not found: `" + filename + "'")
    with open(filename, 'rt') as fin:
        table_branch_map = build_table_branch_map(target_config, fin)
    with open(filename, 'rt') as fin:
        bb_list = build_cfg(target_config, fin, function_name,
                            table_branch_map)
    return bb_list
Ejemplo n.º 6
0
def make_cut_head_list(head_list):
    cut_head = None
    for (index, h) in head_list:
        if h == -1:
            pass
        elif cut_head == None:
            cut_head = h
        elif h < cut_head:
            cut_head = h
        else:
            pass
    if cut_head == None or cut_head == -1:
        driver.data_error('make_cut_head_list')
    cut_head_list = []
    for (index, h) in head_list:
        if h == cut_head:
            cut_head_list.append((index, h))
    return cut_head_list
Ejemplo n.º 7
0
def make_global_title_sub(root_dir, config_name, test_name, metric_name,
                          first_p):
    global result_title
    result_dir = root_dir + "result/" + test_name + "/"
    driver.sure_to_exist(result_dir)
    db_fn = config_name + "--" + test_name + "--" + metric_name + ".json"
    db_filename = result_dir + db_fn
    if verbose_p:
        print("use " + db_filename)
    json_data = load_json_file(db_filename)
    title = get_title(json_data)
    if title[0] != 'TITLE':
        driver.data_error('make_global_title_sub')
    bar = title[1]
    if first_p:
        result_title.extend(bar)
    else:
        result_title.append(-1)
        result_title.extend(bar[2:])
Ejemplo n.º 8
0
def report_t1_cl_ml_sub(root_dir, config_name, test_name, metric_name,
                        part_global_title, first_p):
    global result_table
    global verbose_p
    global only_summary_p
    result_dir = root_dir + "result/" + test_name + "/"
    driver.sure_to_exist(result_dir)
    db_fn = config_name + "--" + test_name + "--" + metric_name + ".json"
    db_filename = result_dir + db_fn
    if verbose_p:
        print("use " + db_filename)
    json_data = load_json_file(db_filename)
    title = get_title(json_data)
    if title[0] != 'TITLE':
        driver.data_error('report_t1_cl_ml_sub 0')
    bar = title[1]
    fix_bar = None
    if first_p:
        fix_bar = bar
    else:
        # Skip "CFG", "SIZE" and "DEPTH"
        fix_bar = bar[3:]
    data_size = len(bar) - 1
    index = 0
    row_list = json_data[1:]
    if only_summary_p:
        row_list = row_list[-1:]
    for row in row_list:
        bb = row[0]
        data = row[1]
        if len(data) != data_size:
            driver.data_error('report_t1_cl_ml_sub 1')
        fix_data = None
        if first_p:
            fix_data = [bb]
            fix_data.extend(data)
        else:
            # Skip BB
            fix_data = data[1:]
        if len(fix_data) != len(fix_bar):
            driver.data_error('report_t1_cl_ml_sub 2')
        fix_data = pad_data(fix_bar, fix_data, part_global_title)
        if first_p:
            result_table.append(fix_data)
        else:
            result_table[index].extend(fix_data)
        index += 1
Ejemplo n.º 9
0
def calculate_score_sub(root_dir, config_name, test_name, metric_name):
    global first_p
    score = 0
    if first_p:
        score += get_dynamic_score(root_dir, test_name, config_name, metric_name)
        first_p = False
    result_dir = root_dir + "result/" + test_name + "/"
    driver.sure_to_exist(result_dir)
    db_fn = config_name + "--" + test_name + "--" + metric_name + ".json"
    db_filename = result_dir + db_fn
    if verbose_p:
        print("use " + db_filename)
    json_data = load_json_file(db_filename)
    title = get_title(json_data)
    if title[0] != 'TITLE':
        driver.data_error('calculate_score_sub 0')
    bar = title[1]
    if verbose_p:
        print(bar)
    data_size = len(bar) - 1
    if json_data[-1][0] != '*SUMMARY*':
        driver.data_error('calculate_score_sub 1')
    for row in json_data[1:-1]:
        bb = row[0]
        data = row[1]
        if len(data) != data_size:
            driver.data_error('calculate_score_sub 1')
        size = data[0]
        depth = data[1]
        if verbose_p:
            print("size=" + size + ",depth=" + depth)
        index = 3
        for d in data[2:]:
            c = bar[index]
            if verbose_p:
                print("index=" + str(index) + ",bar=" + c + ",d=" + d)
            score += get_term_score(metric_name, depth, c, d)
            index += 1
    return score
Ejemplo n.º 10
0
def load_json_file(filename):
    if not os.path.exists(filename):
        driver.data_error("file not found: `" + filename + "'")
    with open(filename, 'rt') as fin:
        json_data = json.load(fin)
    return json_data