Skip to content

Commit

Permalink
SMI-finder debug script
Browse files Browse the repository at this point in the history
  • Loading branch information
cpey committed Jun 16, 2024
1 parent d5069a1 commit 5e377fd
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions scripts/plot_deltas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
# 04-delta-histogram$ python3 process_histogram.py smm-01.log
import sys
import pyjson5
import numpy as np
import matplotlib.pyplot as plt
import statistics
import argparse

def process(args):
with open(args.filename, 'r') as f:
time = 0
start_offset_time = 0
for line in f:
if line.startswith("[*] Fuzzing SMI#"):
ini = line.find("#") + 2
fin = line[ini:].find("(") - 1
smi = line[ini:ini+fin]
elif line.startswith("Deltas:"):
pos = line.find("{")
info = pyjson5.loads(line[pos:])
times = []
init_time = 0
curr_time = 0
count = 0
for i in info['times']:
if not init_time:
init_time = i
curr_time = i - init_time
times.append(curr_time/1e9)
#times.append(count)
count += 1
print(f"SMI# {smi}: Average {sum(info['deltas'])/len(info['deltas'])} counts, Std Dev. {statistics.stdev(info['deltas'])} counts")
plt.plot(times, info['deltas'])
plt.xlabel('Time offset [s]')
plt.ylabel('CPU counts')
if not args.join:
plt.title(f'Duration of the SMI# {smi} over time')
plt.show()
else:
plt.title(f'Duration of the SMIs over time')
plt.draw()
else:
continue
if args.join:
plt.show()

if __name__ == "__main__":
parser = argparse.ArgumentParser(
prog='plot_deltas.py',
description='Plot SMI duration times')
parser.add_argument('filename')
parser.add_argument('-j', '--join', action='store_true')
args = parser.parse_args()
process(args)

0 comments on commit 5e377fd

Please sign in to comment.