Exemplo n.º 1
0
    def __init__(self, run, topology, execname=None, pid=None):
        """Args:
                run (trappy.Run): A single trappy.Run object
                    or a path that can be passed to trappy.Run
                topology(trappy.stats.Topology): The CPU topology
                execname(str, optional): Optional execname of the task
                     under consideration.
                PID(int): The PID of the task to be checked

            One of pid or execname is mandatory. If only execname
            is specified, The current implementation will fail if
            there are more than one processes with the same execname
        """

        run = Utils.init_run(run)

        if not execname and not pid:
            raise ValueError("Need to specify at least one of pid or execname")

        self.execname = execname
        self._run = run
        self._pid = self._validate_pid(pid)
        self._aggs = {}
        self._topology = topology
        self._triggers = sconf.sched_triggers(self._run, self._pid,
                                              trappy.sched.SchedSwitch)
        self.name = "{}-{}".format(self.execname, self._pid)
Exemplo n.º 2
0
    def getThermalResidency(self, temp_range, window, percent=False):
        """Returns the total time spent in a given temperature range
        Args:
            temp_range (tuple): A tuple of (low_temp, high_temp)
                which the specifies the range of temperature that
                one intends to calculate the residency for.
            window (tuple): A (start, end) tuple to limit the scope of the
                residency calculation.
            percent: Returns the residency as a percentage of the total
                duration of the trace
        """

        # Get a pivoted thermal temperature data using the grammar
        data = self._analyzer.getStatement("trappy.thermal.Thermal:temp")

        result = {}
        for pivot, data_frame in data.groupby(axis=1, level=0):

            series = data_frame[pivot]
            series = Utils.select_window(series, window)
            mask = (series >= temp_range[0]) & (series <= temp_range[1])
            index = series.index.values
            # pylint fails to recognize numpy members.
            # pylint: disable=no-member
            shift_index = np.roll(index, 1)
            # pylint: enable=no-member
            shift_index[0] = 0

            result[pivot] = sum((index - shift_index)[mask.values])

            if percent:
                result[pivot] = (
                    result[pivot] * 100.0) / self._run.get_duration()

        return result
Exemplo n.º 3
0
    def __init__(self, run, topology, execname=None, pid=None):
        """Args:
                run (trappy.Run): A single trappy.Run object
                    or a path that can be passed to trappy.Run
                topology(trappy.stats.Topology): The CPU topology
                execname(str, optional): Optional execname of the task
                     under consideration.
                PID(int): The PID of the task to be checked

            One of pid or execname is mandatory. If only execname
            is specified, The current implementation will fail if
            there are more than one processes with the same execname
        """

        run = Utils.init_run(run)

        if not execname and not pid:
            raise ValueError("Need to specify at least one of pid or execname")

        self.execname = execname
        self._run = run
        self._pid = self._validate_pid(pid)
        self._aggs = {}
        self._topology = topology
        self._triggers = sconf.sched_triggers(self._run, self._pid,
                                              trappy.sched.SchedSwitch)
        self.name = "{}-{}".format(self.execname, self._pid)
Exemplo n.º 4
0
    def __init__(self, run, topology, execnames):

        self._execnames = listify(execnames)
        self._run = Utils.init_run(run)
        self._pids = self._populate_pids()
        self._topology = topology
        self._asserts = self._populate_asserts()
        self._populate_methods()
Exemplo n.º 5
0
    def __init__(self, ftrace, topology, execnames=None, pids=None):

        self._ftrace = Utils.init_ftrace(ftrace)
        self._topology = topology

        if execnames and pids:
            raise ValueError('Either pids or execnames must be specified')
        if execnames:
            self._execnames = Utils.listify(execnames)
            self._pids = self._populate_pids()
        elif pids:
            self._pids = pids
        else:
            raise ValueError('One of PIDs or execnames must be specified')

        self._asserts = self._populate_asserts()
        self._populate_methods()
    def __init__(self, ftrace, topology, execnames=None, pids=None):

        self._ftrace = Utils.init_ftrace(ftrace)
        self._topology = topology

        if execnames and pids:
            raise ValueError('Either pids or execnames must be specified')
        if execnames:
            self._execnames = Utils.listify(execnames)
            self._pids = self._populate_pids()
        elif pids:
            self._pids = pids
        else:
            raise ValueError('One of PIDs or execnames must be specified')

        self._asserts = self._populate_asserts()
        self._populate_methods()
Exemplo n.º 7
0
    def __init__(self, run, topology, execnames):

        self._execnames = listify(execnames)
        self._run = Utils.init_run(run)
        self._pids = self._populate_pids()
        self._topology = topology
        self._asserts = self._populate_asserts()
        self._populate_methods()
Exemplo n.º 8
0
    def test_interval_sum(self):
        """Test Utils Function: interval_sum"""

        # A series with a non uniform index
        # Refer to the example illustrations in the
        # the interval sum docs-strings which explains
        # the difference between step-post and ste-pre
        # calculations
        values = [0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1]
        index = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12]
        series = pd.Series(values, index=index)

        self.assertEqual(Utils.interval_sum(series, 1, step="post"), 8)
        self.assertEqual(Utils.interval_sum(series, 1, step="pre"), 7)

        # check left boundary
        array = [1, 1, 0, 0]
        series = pd.Series(array)

        self.assertEqual(Utils.interval_sum(series, 1, step="post"), 2)
        self.assertEqual(Utils.interval_sum(series, 1, step="pre"), 1)

        # check right boundary
        array = [0, 0, 1, 1]
        series = pd.Series(array)

        self.assertEqual(Utils.interval_sum(series, 1, step="post"), 1)
        self.assertEqual(Utils.interval_sum(series, 1, step="pre"), 2)

        array = [False, False, True, True, True, True, False, False]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series), 4)
Exemplo n.º 9
0
    def test_interval_sum(self):
        """Test Utils Function: interval_sum"""

        # A series with a non uniform index
        # Refer to the example illustrations in the
        # the interval sum docs-strings which explains
        # the difference between step-post and ste-pre
        # calculations
        values = [0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1]
        index = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12]
        series = pd.Series(values, index=index)

        self.assertEqual(Utils.interval_sum(series, 1, step="post"), 8)
        self.assertEqual(Utils.interval_sum(series, 1, step="pre"), 7)

        # check left boundary
        array = [1, 1, 0, 0]
        series = pd.Series(array)

        self.assertEqual(Utils.interval_sum(series, 1, step="post"), 2)
        self.assertEqual(Utils.interval_sum(series, 1, step="pre"), 1)

        # check right boundary
        array = [0, 0, 1, 1]
        series = pd.Series(array)

        self.assertEqual(Utils.interval_sum(series, 1, step="post"), 1)
        self.assertEqual(Utils.interval_sum(series, 1, step="pre"), 2)

        array = [False, False, True, True, True, True, False, False]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series), 4)
Exemplo n.º 10
0
    def test_interval_sum(self):
        """Test Utils Function: interval_sum"""

        array = [0, 0, 1, 1, 1, 1, 0, 0]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 3)

        array = [False, False, True, True, True, True, False, False]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series), 3)

        array = [0, 0, 1, 0, 0, 0]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 0)

        array = [0, 0, 1, 0, 1, 1]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 1)
Exemplo n.º 11
0
    def test_interval_sum(self):
        """Test Utils Function: interval_sum"""

        array = [0, 0, 1, 1, 1, 1, 0, 0]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 3)

        array = [False, False, True, True, True, True, False, False]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series), 3)

        array = [0, 0, 1, 0, 0, 0]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 0)

        array = [0, 0, 1, 0, 1, 1]
        series = pd.Series(array)
        self.assertEqual(Utils.interval_sum(series, 1), 1)
Exemplo n.º 12
0
    def test_area_under_curve(self):
        """Test Utils function: area_under_curve"""

        array = [0, 0, 2, 2, 2, 1, 1, 1]
        series = pd.Series(array)

        # Area under curve post stepping
        self.assertEqual(Utils.area_under_curve(series, method="rect", step="post"), 8)

        # Area under curve pre stepping
        self.assertEqual(Utils.area_under_curve(series, method="rect", step="pre"), 9)

        array = [1]
        series = pd.Series(array)

        # Area under curve post stepping, edge case
        self.assertEqual(Utils.area_under_curve(series, method="rect", step="post"), 0)

        # Area under curve pre stepping, edge case
        self.assertEqual(Utils.area_under_curve(series, method="rect", step="pre"), 0)
    def __init__(self,
                 reference_trace,
                 trace,
                 topology,
                 execnames,
                 aggfunc=sched_funcs.csum):

        run = Utils.init_ftrace(trace)
        reference_run = Utils.init_ftrace(reference_trace)

        self._execnames = Utils.listify(execnames)
        self._reference_pids = self._populate_pids(reference_run)
        self._pids = self._populate_pids(run)
        self._dimension = len(self._pids)
        self._topology = topology
        self._matrix = self._generate_matrix(run, reference_run, aggfunc)

        if len(self._pids) != len(self._reference_pids):
            raise RuntimeError(
                "The runs do not have the same number of PIDs for {0}".format(
                    str(execnames)))
Exemplo n.º 14
0
    def __init__(
            self,
            reference_trace,
            trace,
            topology,
            execnames,
            aggfunc=sconf.csum):

        run = Utils.init_run(trace)
        reference_run = Utils.init_run(reference_trace)

        self._execnames = listify(execnames)
        self._reference_pids = self._populate_pids(reference_run)
        self._pids = self._populate_pids(run)
        self._dimension = len(self._pids)
        self._topology = topology
        self._matrix = self._generate_matrix(run, reference_run, aggfunc)

        if len(self._pids) != len(self._reference_pids):
            raise RuntimeError(
                "The runs do not have the same number of PIDs for {0}".format(
                    str(execnames)))
Exemplo n.º 15
0
    def __init__(self, run, topology, execnames):
        """Args:
                run (trappy.Run): A single trappy.Run object
                    or a path that can be passed to trappy.Run
                topology(trappy.stats.Topology): The CPU topology
                execname(str, list): List of execnames or single task
        """

        self._execnames = listify(execnames)
        self._run = Utils.init_run(run)
        self._pids = self._populate_pids()
        self._topology = topology
        self._asserts = self._populate_asserts()
        self._populate_methods()
    def assertFirstCpu(self, cpus, window=None):
        """
        Check if the Task started (first ran on in the duration
        of the trace) on a particular CPU(s)

        :param cpus: A list of acceptable CPUs
        :type cpus: int, list

        .. seealso:: :mod:`bart.sched.SchedAssert.SchedAssert.getFirstCPU`
        """

        first_cpu = self.getFirstCpu(window=window)
        cpus = Utils.listify(cpus)
        return first_cpu in cpus
Exemplo n.º 17
0
    def __init__(self, run, topology, execnames):
        """Args:
                run (trappy.Run): A single trappy.Run object
                    or a path that can be passed to trappy.Run
                topology(trappy.stats.Topology): The CPU topology
                execname(str, list): List of execnames or single task
        """

        self._execnames = listify(execnames)
        self._run = Utils.init_run(run)
        self._pids = self._populate_pids()
        self._topology = topology
        self._asserts = self._populate_asserts()
        self._populate_methods()
Exemplo n.º 18
0
    def __init__(self, run, topology, execname=None, pid=None):

        run = Utils.init_run(run)

        if not execname and not pid:
            raise ValueError("Need to specify at least one of pid or execname")

        self.execname = execname
        self._run = run
        self._pid = self._validate_pid(pid)
        self._aggs = {}
        self._topology = topology
        self._triggers = sconf.sched_triggers(self._run, self._pid,
                                              trappy.sched.SchedSwitch)
        self.name = "{}-{}".format(self.execname, self._pid)
Exemplo n.º 19
0
    def __init__(self, run, topology, execname=None, pid=None):

        run = Utils.init_run(run)

        if not execname and not pid:
            raise ValueError("Need to specify at least one of pid or execname")

        self.execname = execname
        self._run = run
        self._pid = self._validate_pid(pid)
        self._aggs = {}
        self._topology = topology
        self._triggers = sconf.sched_triggers(self._run, self._pid,
                                              trappy.sched.SchedSwitch)
        self.name = "{}-{}".format(self.execname, self._pid)
Exemplo n.º 20
0
    def test_area_under_curve(self):
        """Test Utils function: area_under_curve"""

        array = [0, 0, 2, 2, 2, 1, 1, 1]
        series = pd.Series(array)

        # Area under curve post stepping
        self.assertEqual(
            Utils.area_under_curve(series, method="rect", step="post"), 8)

        # Area under curve pre stepping
        self.assertEqual(
            Utils.area_under_curve(series, method="rect", step="pre"), 9)

        array = [1]
        series = pd.Series(array)

        # Area under curve post stepping, edge case
        self.assertEqual(
            Utils.area_under_curve(series, method="rect", step="post"), 0)

        # Area under curve pre stepping, edge case
        self.assertEqual(
            Utils.area_under_curve(series, method="rect", step="pre"), 0)
    def __init__(self, ftrace, topology, execname=None, pid=None):

        ftrace = Utils.init_ftrace(ftrace)

        if not execname and not pid:
            raise ValueError("Need to specify at least one of pid or execname")

        self.execname = execname
        self._ftrace = ftrace
        self._pid = self._validate_pid(pid)
        self._aggs = {}
        self._topology = topology
        self._triggers = sched_funcs.sched_triggers(self._ftrace, self._pid,
                                              trappy.sched.SchedSwitch)
        self.name = "{}-{}".format(self.execname, self._pid)
Exemplo n.º 22
0
    def __init__(self, run, config=None):

        self._run = Utils.init_run(run)
        self._analyzer = Analyzer(self._run, config)
Exemplo n.º 23
0
    def __init__(self, ftrace, config=None):

        self._ftrace = Utils.init_ftrace(ftrace)
        self._analyzer = Analyzer(self._ftrace, config)
Exemplo n.º 24
0
    def __init__(self, ftrace, config=None):

        self._ftrace = Utils.init_ftrace(ftrace)
        self._analyzer = Analyzer(self._ftrace, config)
Exemplo n.º 25
0
    def __init__(self, run, config=None):

        self._run = Utils.init_run(run)
        self._analyzer = Analyzer(self._run, config)