Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Sep 20, 2024
1 parent 9b03517 commit 36598ff
Showing 3 changed files with 55 additions and 22 deletions.
77 changes: 55 additions & 22 deletions analysis/bpf/timeline_verifier_related_bug_feature.py
Original file line number Diff line number Diff line change
@@ -7,37 +7,70 @@
# Step 1: Convert 'commit_date_timestamp' to 'commit_date' if needed
if 'commit_date_timestamp' in data.columns:
data['commit_date'] = pd.to_datetime(data['commit_date_timestamp'], unit='s')
else:
data['commit_date'] = pd.to_datetime(data['commit_date'])

# Step 2: Filter commits related to instructions logics
instruction_commits = data[data['major_related_logic_component'].str.contains('instruction', case=False, na=False)]
# Step 2: Filter commits related to verifier component within instruction logic
verifier_instruction_features = data[
data['major_related_logic_component'].str.contains('instruction', case=False, na=False) &
data['major_related_implementation_component'].str.contains('verifier', case=False, na=False)
].copy()

# Step 3: Get commits related to verifier component in instruction logic commits
instruction_verifier_commits = instruction_commits[
instruction_commits['major_related_implementation_component'].str.contains('verifier', case=False, na=False)
# Step 3: Categorize verifier instruction commits as 'feature'
verifier_instruction_features = verifier_instruction_features[
~verifier_instruction_features['commit_classification'].str.contains('bug', case=False, na=False)
]

# Step 4: Categorize these commits into feature or bug
instruction_verifier_commits['category'] = instruction_verifier_commits['commit_classification'].apply(
lambda x: 'bug' if 'bug' in x.lower() else 'feature'
)
# Step 4: Filter general bugs related to verifier but not instruction
general_bugs = data[
data['major_related_implementation_component'].str.contains('verifier', case=False, na=False) &
data['commit_classification'].str.contains('bug', case=False, na=False)
].copy()

# Step 5: Group verifier instruction features by month
verifier_features_over_time = verifier_instruction_features.groupby(
verifier_instruction_features['commit_date'].dt.to_period('M')
).size().reset_index(name='verifier_features')

# Step 6: Group general bugs by month
general_bugs_over_time = general_bugs.groupby(
general_bugs['commit_date'].dt.to_period('M')
).size().reset_index(name='general_bugs')

# Step 5: Group by time and category to get the counts
instruction_verifier_commits_over_time = instruction_verifier_commits.groupby(
[instruction_verifier_commits['commit_date'].dt.to_period('M'), 'category']
).size().unstack().fillna(0).reset_index()
# Step 7: Merge the two datasets on the commit_date
merged_data = pd.merge(
verifier_features_over_time,
general_bugs_over_time,
on='commit_date',
how='outer'
).fillna(0)

# Step 6: Convert 'commit_date' back to a timestamp for plotting
instruction_verifier_commits_over_time['commit_date'] = instruction_verifier_commits_over_time['commit_date'].dt.to_timestamp()
# Step 8: Convert 'commit_date' back to timestamp for plotting
merged_data['commit_date'] = merged_data['commit_date'].dt.to_timestamp()

# Step 7: Plot the data on the same figure
plt.figure(figsize=(8, 5))
# Step 9: Sort the data by commit_date
merged_data = merged_data.sort_values('commit_date')

# Plot instruction-related verifier commits (feature and bug)
plt.plot(instruction_verifier_commits_over_time['commit_date'], instruction_verifier_commits_over_time.get('bug', 0), marker='x', label='Instruction-Related Verifier Bugs')
plt.plot(instruction_verifier_commits_over_time['commit_date'], instruction_verifier_commits_over_time.get('feature', 0), marker='s', label='Instruction-Related Verifier Features')
# Step 10: Plot the comparison
plt.figure(figsize=(10, 6))

plt.plot(
merged_data['commit_date'],
merged_data['verifier_features'],
marker='s',
label='Verifier Instruction Features',
color='blue'
)
plt.plot(
merged_data['commit_date'],
merged_data['general_bugs'],
marker='x',
label='General Verifier Bugs',
color='red'
)

# Add titles and labels
plt.title('Instruction-Related Verifier Features/Bugs Over Time')
plt.title('Verifier Instruction Modification vs. General Verifier Bugs Over Time')
plt.xlabel('Date')
plt.ylabel('Number of Commits')
plt.grid(True)
@@ -46,7 +79,7 @@
plt.tight_layout()

# Save the plot as an image
plt.savefig("imgs/instruction_verifier_features_bugs_over_time.png")
plt.savefig("imgs/verifier_features_vs_general_bugs_over_time.png")

# Show the plot
plt.show()
Binary file added imgs/instruction_verifier_bugs_over_time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36598ff

Please sign in to comment.