Example #1
0
def compute_case_score(result, category, score_way, exec_dir, target):
    tmp = category.split()
    length = len(tmp)
    if (length != 4):
        return -3

    result_flag = 1
    score_flag = 2

    if type(result) is types.StringType:
        result_fp = string.atof(result)
    elif type(result) is types.FloatType:
        result_fp = result
    elif type(result) is types.IntType:
        result_fp = result
    else:
        return -4
    #pdb.set_trace()
    # this part should be improved
    func_args = score_way.split()
    score_method = func_args[0]
    if len(func_args) < 2:
        print "The configuration of run the benchmark is wrong"
        return -5
    base = string.atof(func_args[1])
    if len(func_args) >= 3:
        index = string.atof(func_args[2])
    if score_method == "exp_score_compute":
        if result_fp == 0:
            result_score = 0
        else:
            result_score = Scores_method.exp_score_compute(
                result_fp, base, index)
            logging.info("After computing, the result is %f" % result_score)
    else:
        if score_method == "compute_speed_score":
            if result_fp == 0:
                result_score = 0
            else:
                result_score = Scores_method.compute_speed_score(
                    result_fp, base)

    #write the result and the corresponding score to files
    target_name = server_utils.get_host_name(target)
    yaml_dir = os.path.join(exec_dir, "..", "output", "yaml")
    result_yaml_name = target_name + '.yaml'
    score_yaml_name = target_name + "_score.yaml"
    result_yaml = os.path.join(yaml_dir, result_yaml_name)
    score_yaml = os.path.join(yaml_dir, score_yaml_name)

    try:
        flag1 = write_yaml(result_yaml, tmp, result_fp, result_flag)
        flag2 = write_yaml(score_yaml, tmp, result_score, score_flag)
    except BaseException:
        print "There is wrong when compute the score."
    return flag1 & flag2
Example #2
0
def compute_score(score_way, result_fp):
    # this part should be improved
    func_args = score_way.split()
    score_method = func_args[0]
    if len(func_args) < 2:
        logging.info("The configuration of run the benchmark is wrong")
        return -5
    result_score = 0
    base = string.atof(func_args[1])
    if len(func_args) >= 3:
        index = string.atof(func_args[2])
    if score_method == "exp_score_compute":
        if result_fp == 0:
            result_score = 0
        else:
            try:
                result_score = Scores_method.exp_score_compute(result_fp,
                                                                base, index)
                logging.debug("After computing, the result is %f" %
                                result_score)
            except Exception, e:
                raise e
Example #3
0
        else:
            try:
                result_score = Scores_method.exp_score_compute(result_fp,
                                                                base, index)
                logging.debug("After computing, the result is %f" %
                                result_score)
            except Exception, e:
                raise e
    else:
        if score_method == "compute_speed_score":
            if result_fp == 0:
                result_score = 0
            else:
                try:
                    result_score = Scores_method.compute_speed_score(
                                                            result_fp,
                                                            base)
                except Exception, e:
                    raise e
    return result_score



def write_yaml_func(yaml_file, tmp, result, kind):
    return write_yaml_perf(yaml_file, tmp, result, kind)

def write_dic(result, tmp, score_way, yaml_file, file_flag):
    flag = 0
    for key in result.keys():
        if type(result[key]) == dict:
            sub_dic = result[key]