mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-09 13:31:53 +01:00
utils/gem5: try to cast statistics dump values
All values in the gem5 statistics log file are numeric. This commit adds a cast on the strings read from the stats file to native numeric values when and logs a warning in case of a malformed entry.
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
import re
|
||||
import logging
|
||||
|
||||
from devlib.utils.types import numeric
|
||||
|
||||
|
||||
GEM5STATS_FIELD_REGEX = re.compile("^(?P<key>[^- ]\S*) +(?P<value>[^#]+).+$")
|
||||
@@ -20,6 +23,8 @@ GEM5STATS_DUMP_HEAD = '---------- Begin Simulation Statistics ----------'
|
||||
GEM5STATS_DUMP_TAIL = '---------- End Simulation Statistics ----------'
|
||||
GEM5STATS_ROI_NUMBER = 8
|
||||
|
||||
logger = logging.getLogger('gem5')
|
||||
|
||||
|
||||
def iter_statistics_dump(stats_file):
|
||||
'''
|
||||
@@ -38,6 +43,11 @@ def iter_statistics_dump(stats_file):
|
||||
res = GEM5STATS_FIELD_REGEX.match(line)
|
||||
if res:
|
||||
k = res.group("key")
|
||||
v = res.group("value").split()
|
||||
cur_dump[k] = v[0] if len(v)==1 else set(v)
|
||||
vtext = res.group("value")
|
||||
try:
|
||||
v = map(numeric, vtext.split())
|
||||
cur_dump[k] = v[0] if len(v)==1 else set(v)
|
||||
except ValueError:
|
||||
msg = 'Found non-numeric entry in gem5 stats ({}: {})'
|
||||
logger.warning(msg.format(k, vtext))
|
||||
|
||||
|
Reference in New Issue
Block a user