def analyze_simulation_outputs(path):
    golden_output, fault_outputs = load_outputs([path])
    golden_output = golden_output[0]
    fault_outputs = fault_outputs[0]
    global_faults_count = 0
    global_nans_count = 0
    global_zeros_count = 0
    global_diff = np.zeros((0))
    global_bit_classes = {}
    for fault_output in fault_outputs:
        faults_count, nans_count, zeros_count, diff, bit_classes = count_faults(golden_output, fault_output)
        global_faults_count += faults_count
        global_nans_count += nans_count
        global_zeros_count += zeros_count
        global_diff = np.concatenate((global_diff, diff))
        for bit_class_key, bit_class_count in bit_classes.items():
            if bit_class_key not in global_bit_classes:
                global_bit_classes[bit_class_key] = 0
            global_bit_classes[bit_class_key] += bit_class_count
    return global_faults_count, global_nans_count, global_zeros_count, global_diff, global_bit_classes
Пример #2
0
def main():
    paths = get_data_paths()
    counters = {}
    diffs = {}
    nans = {}
    for path in paths:
        golden_output, fault_outputs = load_outputs([path])
        golden_output = golden_output[0]
        fault_outputs = fault_outputs[0]
        for fault_output in fault_outputs:
            faults, nan, values_diff = count_faults(golden_output, fault_output)
            if faults not in counters:
                counters[int(faults)] = 0
            counters[int(faults)] += faults
            if faults not in nans:
                nans[int(faults)] = 0
            nans[int(faults)] += nan
            if faults not in diffs:
                diffs[int(faults)] = np.zeros((0))
            diffs[int(faults)] = np.concatenate((diffs[faults], values_diff))
    dd = np.zeros((0))
    for faults in sorted(counters.keys()):
        nan_p = nans[faults] / counters[faults]
        print("Faults: {}".format(faults))
        print("NaN percentage: {:.5f}".format(nan_p))
        print("Min value: {:.5f}".format(diffs[faults].min()))
        print("Max value: {:.5f}".format(diffs[faults].max()))
        stat, p = shapiro(diffs[faults])
        print("Gaussian test (Saphiro-Wilk): {}".format(True if p > 0.05 else False))
        stat, p = normaltest(diffs[faults])
        print("Gaussian test (D'agostino): {}".format(True if p > 0.05 else False))
        print("\n")
        dd = np.concatenate((diffs[faults], dd))
    #np.save("counters", counters)
    #np.save("diffs", diffs)
    #np.save("nans", nans)
    to_json(counters, "counters.json")
    to_json(nans, "nans.json")
    #to_json(diffs, "diffs.json")
    np.save("global_diffs", dd)