def print_taskset(taskset, format): util = .0 # Total utilization hp = 1 # Hyperperiod for t in range(numpy.size(taskset,0)): util += taskset[t][1] hp = lcm(hp, taskset[t][2]) print "<taskset>" print "<properties hyperperiod=\"%d\" utilization=\"%.10f\" />" % (hp, util) for t in range(numpy.size(taskset,0)): #data = { 'Ugen' : taskset[t][0], 'U' : taskset[t][1], 'T' : taskset[t][2], 'C' : taskset[t][3] } print "<task wcet=\"%.10f\" period=\"%d\" utilization=\"%.10f\"/>" % (taskset[t][3], taskset[t][2], taskset[t][1]) print "</taskset>"
def hyperperiod(self): return lcm(*[t.period for t in self])
def test_topsum(self): vals = [30, 60, 10, 40, 50, 20] self.assertEqual(m.topsum(vals, lambda x: x * 2, 3), 2 * (40 + 50 + 60)) self.assertEqual(m.lcm(99), 99) self.assertEqual(m.lcm(10, 20, 3), 60)
def test_lcm(self): self.assertEqual(m.lcm(), 0) self.assertEqual(m.lcm(99), 99) self.assertEqual(m.lcm(10, 20, 3), 60) self.assertEqual(m.lcm(10, 20), 20) self.assertEqual(m.lcm(3, 4), 12)