Skip to content

Commit 907c8c8

Browse files
committed
Correct mutation probabilities for known values
1 parent e9ff6c3 commit 907c8c8

1 file changed

Lines changed: 34 additions & 14 deletions

File tree

utbot-fuzzing/src/main/resources/loganal.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33
import re
4+
import argparse
45
import pandas as pd
56
from tqdm import tqdm
67
from matplotlib import pyplot as plt
@@ -50,20 +51,19 @@ def build_dataframe(logpath: str):
5051
except:
5152
pass
5253

53-
return (pd.DataFrame(data,
54-
columns = ['class_name', 'method', 'value'] + list(mutation_labels) + ['line_number', 'trace_hash', 'trace_count', 'event', 'time']
55-
),
56-
list(mutation_labels))
54+
df = pd.DataFrame(data, columns =
55+
['class_name', 'method', 'value'] + list(mutation_labels) +
56+
['line_number', 'trace_hash', 'trace_count', 'event', 'time'])
57+
df = df.assign(new_feedbacks_count = (df.event == 'NEW_FEEDBACK').cumsum())
5758

59+
return (df, list(mutation_labels))
5860

59-
if __name__ == "__main__":
60-
(df, mutation_labels) = build_dataframe(sys.argv[1])
61-
df = df.assign(new_feedbacks_count = (df.event == 'NEW_FEEDBACK').cumsum())
62-
61+
def draw_report(df: pd.DataFrame, mutations_labels: list, title: str):
6362
plt.figure(0)
64-
ax1 = plt.subplot2grid((2,3), (0,0), colspan=2)
65-
ax2 = plt.subplot2grid((2,3), (0,2))
66-
ax3 = plt.subplot2grid((2,3), (1,0), colspan=3)
63+
ax1 = plt.subplot2grid((3,3), (0,0), colspan=2)
64+
ax2 = plt.subplot2grid((3,3), (0,2))
65+
ax3 = plt.subplot2grid((3,3), (1,0), colspan=3)
66+
ax4 = plt.subplot2grid((3,3), (2,0), colspan=3)
6767

6868
ax1.set_title('Specific effectiveness')
6969
[ ax1.plot( df.index, (df[label]*df.new_feedbacks_count.diff()).cumsum() / df[label].cumsum()) for label in mutation_labels ]
@@ -75,15 +75,35 @@ def build_dataframe(logpath: str):
7575

7676
ax2.set_title('Total specific effectiveness')
7777
ax2.bar(mutation_labels, [ (df[label] * df.new_feedbacks_count.diff()).sum() / df[label].sum() for label in mutation_labels] )
78-
# ax2.grid(axis='y')
78+
ax2.grid(axis='y')
7979

8080
ax3.set_title('Number of discovered traces')
8181
[ ax3.plot(df.index, (df.new_feedbacks_count.diff() * df[label]).cumsum()) for label in mutation_labels ]
82-
plt.plot(df.index, df.new_feedbacks_count)
82+
ax3.plot(df.index, df.new_feedbacks_count)
8383
ax3.legend(labels = mutation_labels + ['Overall'])
8484
ax3.set_xlabel('Iteration')
8585
ax3.set_ylabel('Number of traces')
8686
ax3.grid()
8787

88-
plt.suptitle('Regular traces')
88+
[ ax4.plot(df.index[50:], (df[label].cumsum() / df.index)[50:]) for label in mutation_labels ]
89+
ax4.legend(labels=mutation_labels)
90+
ax4.set_xlabel('Iteration')
91+
ax4.set_ylabel('Number of mutations')
92+
ax4.grid()
93+
94+
if title:
95+
plt.suptitle(title)
96+
8997
plt.show()
98+
99+
100+
if __name__ == '__main__':
101+
parser = argparse.ArgumentParser()
102+
parser.add_argument('path', help='Log file path', type=str)
103+
parser.add_argument('--title', help='Report title', type=str)
104+
args = parser.parse_args()
105+
106+
(df, mutation_labels) = build_dataframe(args.path)
107+
108+
draw_report(df, mutation_labels, args.title)
109+

0 commit comments

Comments
 (0)