def test_get_runtime(self): r = trappy.Run() # The ls process is process we are # testing against with pre calculated # values process = "ls" # Complete duration expected_time = 0.0034740000264719129 s = SchedAssert(r, self.topology, execname=process) self.assertAlmostEqual(s.getRuntime(), expected_time, places=9) self.assertAlmostEqual(s.getRuntime(), expected_time, places=9) # Non Interrupted Window window = (0.0034, 0.003525) expected_time = 0.000125 self.assertAlmostEqual(s.getRuntime(window=window), expected_time, places=9) # Interrupted Window window = (0.0030, 0.0032) expected_time = 0.000166 self.assertAlmostEqual(s.getRuntime(window=window), expected_time, places=9) # A window with multiple interruptions window = (0.0027, 0.0036) expected_time = 0.000817 self.assertAlmostEqual(s.getRuntime(window=window), expected_time, places=9)
def calculate_end_times(cls): end_times = {} for task in cls.params.keys(): sched_assert = SchedAssert(cls.trace, cls.env.topology, execname=task) end_times[task] = sched_assert.getEndTime() return end_times
def get_end_times(self, experiment): """ Get the time at which each task in the workload finished Returned as a dict; {"task_name": finish_time, ...} """ end_times = {} ftrace = self.get_trace(experiment).ftrace for task in experiment.wload.tasks.keys(): sched_assert = SchedAssert(ftrace, self.te.topology, execname=task) end_times[task] = sched_assert.getEndTime() return end_times
def test_all_tasks_finish_on_a_big_cpu(self): """Offload Migration and Idle Pull: All tasks finish on a big cpu Note: this test may fail in big.LITTLE systems where the little cpus' performance is comparable to the bigs' and they can take almost the same time as a big cpu to complete a task. """ for task in self.params.keys(): sa = SchedAssert(self.trace, self.env.topology, execname=task) msg = "Task {} did not finish on a big cpu".format(task) self.assertIn(sa.getLastCpu(), self.env.target.bl.bigs, msg=msg)
def get_sched_assert(self, experiment, task): """ Return a SchedAssert over the task provided """ return SchedAssert(self.get_trace(experiment).ftrace, self.te.topology, execname=task)
def get_task_duty_cycle_pct(cls, trace, task_name, cpu): window = cls.get_task_window(trace, task_name, cpu) top = Topology() top.add_to_level('cpu', [[cpu]]) return SchedAssert(trace._ftrace, top, execname=task_name).getDutyCycle(window)
def test_all_tasks_run_on_a_big_cpu(self): """Offload Migration and Idle Pull: All tasks run on a big cpu at some point Note: this test may fail in big.LITTLE platforms in which the little cpus are almost as performant as the big ones. """ for task in self.params.keys(): sa = SchedAssert(self.trace, self.env.topology, execname=task) window = (0, self.end_times[task]) big_residency = sa.getResidency("cluster", self.env.target.bl.bigs, window=window, percent=True) log_result(big_residency, self.log_fh) msg = "Task {} didn't run on a big cpu.".format(task) self.assertGreater(big_residency, 0, msg=msg)
def _populate_asserts(self): """Populate SchedAsserts for the PIDs""" asserts = {} for pid in self._pids: asserts[pid] = SchedAssert(self._ftrace, self._topology, pid=pid) return asserts
def test_get_last_cpu(self): """SchedAssert.getLastCpu() gives you the last cpu in which a task ran""" expected_last_cpu = 5 sa = SchedAssert("trace.dat", self.topology, execname="ls") self.assertEqual(sa.getLastCpu(), expected_last_cpu)
def get_offset(cls, task_name): return SchedAssert(cls.trace_file, cls.env.topology, execname=task_name).getStartTime()