diff --git a/src/python/SConscript b/src/python/SConscript index f08752af1a..66e984261d 100644 --- a/src/python/SConscript +++ b/src/python/SConscript @@ -284,6 +284,7 @@ PySource('m5.ext.pyfdt', 'm5/ext/pyfdt/__init__.py') PySource('m5.ext.pystats', 'm5/ext/pystats/__init__.py') PySource('m5.ext.pystats', 'm5/ext/pystats/serializable_stat.py') +PySource('m5.ext.pystats', 'm5/ext/pystats/abstract_stat.py') PySource('m5.ext.pystats', 'm5/ext/pystats/group.py') PySource('m5.ext.pystats', 'm5/ext/pystats/simstat.py') PySource('m5.ext.pystats', 'm5/ext/pystats/statistic.py') diff --git a/src/python/m5/ext/pystats/__init__.py b/src/python/m5/ext/pystats/__init__.py index 942979a1a8..32cee43296 100644 --- a/src/python/m5/ext/pystats/__init__.py +++ b/src/python/m5/ext/pystats/__init__.py @@ -24,6 +24,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from .abstract_stat import AbstractStat from .serializable_stat import SerializableStat from .group import Group from .simstat import SimStat @@ -33,6 +34,7 @@ from .timeconversion import TimeConversion from .jsonloader import JsonLoader __all__ = [ + "AbstractStat", "Group", "SimStat", "Statistic", diff --git a/src/python/m5/ext/pystats/abstract_stat.py b/src/python/m5/ext/pystats/abstract_stat.py new file mode 100644 index 0000000000..511ee363e0 --- /dev/null +++ b/src/python/m5/ext/pystats/abstract_stat.py @@ -0,0 +1,37 @@ +# Copyright (c) 2022 The Regents of The University of California +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from .serializable_stat import SerializableStat + + +class AbstractStat(SerializableStat): + """ + An abstract class which all PyStats inherit from. + + All PyStats are JsonSerializable. + """ + + pass diff --git a/src/python/m5/ext/pystats/group.py b/src/python/m5/ext/pystats/group.py index 680a5d547a..7fcd665ffe 100644 --- a/src/python/m5/ext/pystats/group.py +++ b/src/python/m5/ext/pystats/group.py @@ -36,12 +36,12 @@ from typing import ( Union, ) -from .serializable_stat import SerializableStat +from .abstract_stat import AbstractStat from .statistic import Scalar, Statistic from .timeconversion import TimeConversion -class Group(SerializableStat): +class Group(AbstractStat): """ Used to create the heirarchical stats structure. A Group object contains a map of labeled Groups, Statistics, Lists of Groups, or List of Statistics. diff --git a/src/python/m5/ext/pystats/simstat.py b/src/python/m5/ext/pystats/simstat.py index bab47cce84..c7c28f419a 100644 --- a/src/python/m5/ext/pystats/simstat.py +++ b/src/python/m5/ext/pystats/simstat.py @@ -27,13 +27,13 @@ from datetime import datetime from typing import Dict, List, Optional, Union -from .serializable_stat import SerializableStat +from .abstract_stat import AbstractStat from .group import Group from .statistic import Statistic from .timeconversion import TimeConversion -class SimStat(SerializableStat): +class SimStat(AbstractStat): """ Contains all the statistics for a given simulation. """ diff --git a/src/python/m5/ext/pystats/statistic.py b/src/python/m5/ext/pystats/statistic.py index b018060ddc..4111bde23e 100644 --- a/src/python/m5/ext/pystats/statistic.py +++ b/src/python/m5/ext/pystats/statistic.py @@ -27,11 +27,11 @@ from abc import ABC from typing import Any, Iterable, Optional, Union, List -from .serializable_stat import SerializableStat +from .abstract_stat import AbstractStat from .storagetype import StorageType -class Statistic(ABC, SerializableStat): +class Statistic(ABC, AbstractStat): """ The abstract base class for all Python statistics. """