forked from OpenXiangShan/XiangShan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utils: support performance rolling tool and corresponding scripts (Op…
…enXiangShan#2228) * utils: support perf rolling data collection through chiseldb * perf: add ipc rollingperf * script: add rolling plot script * param: disable rollingdb by default * misc: fix typo
- Loading branch information
Showing
4 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import sys | ||
import argparse | ||
import sqlite3 | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
|
||
# usage: python3 rollingplot.py DB_FILE_PATH PERF_NAME [--aggregate AGGREGATE_RATIO] | ||
|
||
|
||
class DataSet: | ||
|
||
def __init__(self, db_path): | ||
self.conn = sqlite3.connect(db_path) | ||
self.cursor = self.conn.cursor() | ||
self.xdata = [] | ||
self.ydata = [] | ||
|
||
def derive(self, perf_name, aggregate, hart): | ||
sql = "SELECT xAxisPt, yAxisPt FROM {}_rolling_{}".format(perf_name, hart) | ||
self.cursor.execute(sql) | ||
result = self.cursor.fetchall() | ||
granularity = result[1][0] - result[0][0] | ||
aggcnt = 0 | ||
aggydata = 0 | ||
for row in result: | ||
aggcnt += 1 | ||
aggydata += row[1] | ||
if aggcnt == aggregate: | ||
self.xdata.append(row[0]) | ||
self.ydata.append(aggydata/(granularity*aggregate)) | ||
aggcnt = 0 | ||
aggydata = 0 | ||
|
||
def plot(self): | ||
plt.plot(self.xdata, self.ydata, lw=1, ls='-', c='black') | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="performance rolling plot script for xs") | ||
parser.add_argument('db_path', metavar='db_path', type=str, help='path to chiseldb file') | ||
parser.add_argument('perf_name', metavar='perf_name', type=str, help="name of the performance counter") | ||
parser.add_argument('--aggregate', '-A', default=1, type=int, help="aggregation ratio") | ||
args = parser.parse_args() | ||
|
||
if args.aggregate <= 0: | ||
print("aggregation ratio must be no less than 1") | ||
sys.exit(1) | ||
|
||
db_path = args.db_path | ||
perf_name = args.perf_name | ||
aggregate = args.aggregate | ||
|
||
dataset = DataSet(db_path) | ||
dataset.derive(perf_name, aggregate, 0) | ||
dataset.plot() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters