Skip to content

Commit

Permalink
Fix toplev and genretlat for python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Dec 5, 2023
1 parent 207625a commit 3a84ecf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions genretlat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8
# generate return latencies to tune toplev model
# Copyright (c) 2023, Intel Corporation
# Author: Andi Kleen
Expand All @@ -11,6 +12,7 @@
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
from __future__ import print_function
import subprocess as subp
import os
import sys
Expand Down Expand Up @@ -138,14 +140,14 @@ def gen_stat(samples):
def human_output(data):
d = data["Data"]
for ev in sorted(d.keys()):
print(f"{ev}: ", end="")
print("%s: " % ev, end="")
for m in sorted(d[ev].keys()):
if m.startswith("SPARK"):
l = [int(x) for x in d[ev][m].split(",")]
s = gen_spark(l, d[ev]["MIN"], d[ev]["F_NZ" if m.endswith("_NZ") else "F"])
print(f"{m.lower()} {s} ", end="")
print("%s %s " % (m.lower(), s), end="")
else:
print(f"{m.lower()} {d[ev][m]} ", end="")
print("%s %s " % (m.lower(), d[ev][m]), end="")
print()

def find_model():
Expand Down
4 changes: 2 additions & 2 deletions toplev.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ def setup_retlatency(args):
try:
l = args.ret_latency.split(":")
ret_latency = json.load(open(l[0]))["Data"]
except FileNotFoundError:
except IOError:
sys.exit("Cannot open %s" % l[0])
except KeyError:
sys.exit("retlat file has unparseable format")
Expand Down Expand Up @@ -3969,7 +3969,7 @@ def load_default_retlat():
fn = os.path.dirname(os.path.realpath(__file__)) + ("/%s-retlat.json" % name)
try:
ret_latency = json.load(open(fn))["Data"]
except FileNotFoundError:
except IOError:
sys.exit("Cannot find default ret latency file %s\n" % fn +
"Please generate with representative workload using genretlat -o %s workload" % fn)

Expand Down

0 comments on commit 3a84ecf

Please sign in to comment.