From 68f8c2946d0210f69de6c773c62b7ade85fb3359 Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Wed, 7 Sep 2022 12:34:17 -0700 Subject: [PATCH] stdlib: Add 'get_simstats' function to simulator Change-Id: Iedf937a66f33c5a5feada4ffbf550540f65680d1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/63272 Tested-by: kokoro Maintainer: Jason Lowe-Power Reviewed-by: Jason Lowe-Power --- src/python/gem5/simulate/simulator.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/python/gem5/simulate/simulator.py b/src/python/gem5/simulate/simulator.py index 5a4ab171de..8be915efa9 100644 --- a/src/python/gem5/simulate/simulator.py +++ b/src/python/gem5/simulate/simulator.py @@ -27,7 +27,7 @@ import m5 import m5.ticks from m5.stats import addStatVisitor -from m5.stats.gem5stats import get_simstat +from m5.ext.pystats.simstat import SimStat from m5.objects import Root from m5.util import warn @@ -275,8 +275,20 @@ class Simulator: Obtain the current simulation statistics as a Dictionary, conforming to a JSON-style schema. - **Warning:** Will throw an Exception if called before `run()`. The - board must be initialized before obtaining statistics + :raises Exception: An exception is raised if this function is called + before `run()`. The board must be initialized before obtaining + statistics. + """ + + return self.get_simstats().to_json() + + def get_simstats(self) -> SimStat: + """ + Obtains the SimStat of the current simulation. + + :raises Exception: An exception is raised if this function is called + before `run()`. The board must be initialized before obtaining + statistics. """ if not self._instantiated: @@ -284,7 +296,7 @@ class Simulator: "Cannot obtain simulation statistics prior to inialization." ) - return get_simstat(self._root).to_json() + return m5.stats.gem5stats.get_simstat(self._root) def add_text_stats_output(self, path: str) -> None: """