| 1 | import sys
|
|---|
| 2 | import csv
|
|---|
| 3 |
|
|---|
| 4 | data=[]
|
|---|
| 5 | with open(sys.argv[1],'r') as csvfile:
|
|---|
| 6 | content = csv.reader(csvfile, delimiter=',')
|
|---|
| 7 | for line in content:
|
|---|
| 8 | data.append(line)
|
|---|
| 9 |
|
|---|
| 10 | benchmarks={}
|
|---|
| 11 | for line in data[1:]:
|
|---|
| 12 | benchmarks.setdefault(line[1],[]).append({"truth":line[3], "races":int(line[6]), "compiler":line[9], "runtime":line[10]})
|
|---|
| 13 |
|
|---|
| 14 | truePositive = 0
|
|---|
| 15 | falsePositive = 0
|
|---|
| 16 | trueNegative = 0
|
|---|
| 17 | falseNegative = 0
|
|---|
| 18 | compilertrue = 0
|
|---|
| 19 | compilererror = 0
|
|---|
| 20 | compilertimeout = 0
|
|---|
| 21 | runtimeerror = 0
|
|---|
| 22 | runtimetrue = 0
|
|---|
| 23 | runtimeout = 0
|
|---|
| 24 | runtimeoutreport = 0
|
|---|
| 25 | positive = 0
|
|---|
| 26 | negative = 0
|
|---|
| 27 |
|
|---|
| 28 | Nbenchmarks={}
|
|---|
| 29 |
|
|---|
| 30 | for app,runs in benchmarks.items():
|
|---|
| 31 | Nbenchmarks[app]=runs[0]
|
|---|
| 32 | for run in runs[1:]:
|
|---|
| 33 | if Nbenchmarks[app]["races"]<run["races"]:
|
|---|
| 34 | Nbenchmarks[app]["races"]=run["races"]
|
|---|
| 35 |
|
|---|
| 36 | def classify(truth, races):
|
|---|
| 37 | global positive, negative, falseNegative, truePositive, trueNegative, falsePositive
|
|---|
| 38 | if truth.upper() == 'TRUE':
|
|---|
| 39 | positive += 1
|
|---|
| 40 | if races == 0:
|
|---|
| 41 | falseNegative += 1
|
|---|
| 42 | else:
|
|---|
| 43 | truePositive += 1
|
|---|
| 44 | else:
|
|---|
| 45 | negative += 1
|
|---|
| 46 | if races == 0:
|
|---|
| 47 | trueNegative += 1
|
|---|
| 48 | else:
|
|---|
| 49 | falsePositive += 1
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | for app,run in Nbenchmarks.items():
|
|---|
| 53 | if run["compiler"] == '0':
|
|---|
| 54 | compilertrue += 1
|
|---|
| 55 | if run["runtime"] == '0':
|
|---|
| 56 | classify(run["truth"], run["races"])
|
|---|
| 57 | runtimetrue += 1
|
|---|
| 58 | elif run["runtime"] == '11':
|
|---|
| 59 | runtimeerror += 1
|
|---|
| 60 | elif run["runtime"] == '124':
|
|---|
| 61 | if (run["races"]>0):
|
|---|
| 62 | classify(run["truth"], run["races"])
|
|---|
| 63 | runtimeoutreport += 1
|
|---|
| 64 | else:
|
|---|
| 65 | runtimeout += 1
|
|---|
| 66 | else:
|
|---|
| 67 | print(app, run["runtime"], "there are some errors in your runtime data.")
|
|---|
| 68 | elif run["compiler"] in ('1', '2', '4', '134', '254'):
|
|---|
| 69 | compilererror += 1
|
|---|
| 70 | elif run["compiler"] == '11':
|
|---|
| 71 | compilertimeout += 1
|
|---|
| 72 | else:
|
|---|
| 73 | print(app, run["compiler"], "there are some errors in your compiler data.")
|
|---|
| 74 |
|
|---|
| 75 | print("total test case is ", len(Nbenchmarks))
|
|---|
| 76 | print("compiler segmentation fault is ", compilererror)
|
|---|
| 77 | print("runtime segmentation fault is ", runtimeerror)
|
|---|
| 78 | print("compiler time out is ", compilertimeout)
|
|---|
| 79 | print("runtime time out is ", runtimeout)
|
|---|
| 80 | print("runtime time out with report is ", runtimeoutreport)
|
|---|
| 81 | print("tool success rate is ", (negative+positive)/(len(Nbenchmarks)))
|
|---|
| 82 | print("false positive is ", falsePositive)
|
|---|
| 83 | print("true positive is ", truePositive)
|
|---|
| 84 | print("true negative is ", trueNegative)
|
|---|
| 85 | print("false negative is ", falseNegative)
|
|---|
| 86 | Accuracy = (truePositive + trueNegative) / (negative+positive)
|
|---|
| 87 | if (trueNegative+falsePositive) != 0:
|
|---|
| 88 | Specificity = (trueNegative)/(trueNegative+falsePositive)
|
|---|
| 89 | else:
|
|---|
| 90 | Specificity = 'N/A'
|
|---|
| 91 | if (truePositive + falsePositive) != 0:
|
|---|
| 92 | Precision = truePositive / (truePositive + falsePositive)
|
|---|
| 93 | else:
|
|---|
| 94 | Precision = 'N/A'
|
|---|
| 95 | if (truePositive + falseNegative) != 0:
|
|---|
| 96 | Recall = truePositive / (truePositive + falseNegative)
|
|---|
| 97 | else:
|
|---|
| 98 | Recall = 'N/A'
|
|---|
| 99 | if Specificity == 'N/A' or Precision == 'N/A' or Recall == 'N/A':
|
|---|
| 100 | f1Score = 'N/A'
|
|---|
| 101 | else:
|
|---|
| 102 | f1Score = 2 * Precision * Recall / (Precision + Recall)
|
|---|
| 103 | print("Accuracy is ", Accuracy)
|
|---|
| 104 | print("Precision is", Precision)
|
|---|
| 105 | print("Specificity is ", Specificity)
|
|---|
| 106 | print("Recall is ", Recall)
|
|---|
| 107 | print("F1 Score is ", f1Score)
|
|---|