当前位置: 首页>>代码示例>>Python>>正文


Python Scheduler.print_schedule方法代码示例

本文整理汇总了Python中scheduler.Scheduler.print_schedule方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.print_schedule方法的具体用法?Python Scheduler.print_schedule怎么用?Python Scheduler.print_schedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scheduler.Scheduler的用法示例。


在下文中一共展示了Scheduler.print_schedule方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_schedule2

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import print_schedule [as 别名]
    def test_schedule2(self):
        metric_1 = Metric(1, 60, [1, 2, 4, 5, 6, 9, 47, 48, 49, 50])
        metric_2 = Metric(2, 60, [1, 2, 4, 5, 6, 9, 47, 48, 49, 50])
        metrics = [metric_1, metric_2]

        task_1 = Task(1, u'200.0.0.1', u'200.0.0.2', 1, 1800, 0)
        task_2 = Task(2, u'200.0.0.1', u'200.0.0.2', 2, 3600, 0)
        task_3 = Task(3, u'200.0.0.2', u'200.0.0.1', 1, 2400, 0)
        task_4 = Task(4, u'200.0.0.2', u'200.0.0.1', 2, 1440, 0)
        task_5 = Task(5, u'200.0.0.2', u'200.0.0.1', 2, 3600, 0)

        tasks = [task_1, task_2, task_3, task_4]
        scheduler = Scheduler(4, metrics)
        scheduler.add_tasks(tasks)
        scheduler.print_schedule()

        self.assertEqual(1, scheduler.schedules[0].task_id)
        self.assertEqual(0, scheduler.schedules[0].start)
        self.assertEqual(1, scheduler.schedules[1].task_id)
        self.assertEqual(1800, scheduler.schedules[1].start)
        self.assertEqual(1, scheduler.schedules[2].task_id)
        self.assertEqual(3600, scheduler.schedules[2].start)
        self.assertEqual(1, scheduler.schedules[3].task_id)
        self.assertEqual(5400, scheduler.schedules[3].start)
        self.assertEqual(2, scheduler.schedules[4].task_id)
        self.assertEqual(60, scheduler.schedules[4].start)
        self.assertEqual(2, scheduler.schedules[5].task_id)
        self.assertEqual(3660, scheduler.schedules[5].start)
        self.assertEqual(3, scheduler.schedules[6].task_id)
        self.assertEqual(120, scheduler.schedules[6].start)
        self.assertEqual(3, scheduler.schedules[7].task_id)
        self.assertEqual(2400, scheduler.schedules[7].start)
        self.assertEqual(3, scheduler.schedules[8].task_id)
        self.assertEqual(4800, scheduler.schedules[8].start)
        self.assertEqual(4, scheduler.schedules[9].task_id)
        self.assertEqual(180, scheduler.schedules[9].start)
        self.assertEqual(4, scheduler.schedules[10].task_id)
        self.assertEqual(1440, scheduler.schedules[10].start)
        self.assertEqual(4, scheduler.schedules[11].task_id)
        self.assertEqual(2880, scheduler.schedules[11].start)
        self.assertEqual(4, scheduler.schedules[12].task_id)
        self.assertEqual(4320, scheduler.schedules[12].start)
        self.assertEqual(4, scheduler.schedules[13].task_id)
        self.assertEqual(5760, scheduler.schedules[13].start)
        scheduler.add_new_task(task_5)
        scheduler.print_schedule()
        #scheduler.print_table()

        scheduler.delete_task(task_2)
        scheduler.print_schedule()
        scheduler.delete_task(task_3)
        scheduler.print_schedule()
        #scheduler.print_table()

        scheduler.add_new_task(task_3)
        scheduler.print_schedule()
开发者ID:LonghaiCui,项目名称:NaradaMetrics_Scheduler,代码行数:58,代码来源:scheduler+copy.py

示例2: test_basic_schedule1

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import print_schedule [as 别名]
    def test_basic_schedule1(self):
        task_1 = Task(11, "MPA1", "MPA2", 1, 30, 0)
        task_2 = Task(22, "MPA1", "MPA2", 2, 60, 0)
        task_3 = Task(33, "MPA2", "MPA1", 1, 40, 0)
        task_4 = Task(44, "MPA2", "MPA1", 2, 24, 0)

        task_5 = Task(55, "MPA2", "MPA1", 2, 60, 0)
        metrics = [self.metric_1, self.metric_2]
        scheduler = Scheduler(4, metrics)

        tasks = [task_1, task_2, task_3, task_4]

        scheduler.add_tasks(tasks)
        scheduler.print_schedule()
        scheduler.print_table()

        self.assertEqual(11, scheduler.schedules[0].task_id)
        self.assertEqual(0, scheduler.schedules[0].start)
        self.assertEqual(11, scheduler.schedules[1].task_id)
        self.assertEqual(30, scheduler.schedules[1].start)
        self.assertEqual(11, scheduler.schedules[2].task_id)
        self.assertEqual(60, scheduler.schedules[2].start)
        self.assertEqual(11, scheduler.schedules[3].task_id)
        self.assertEqual(90, scheduler.schedules[3].start)
        self.assertEqual(22, scheduler.schedules[4].task_id)
        self.assertEqual(1, scheduler.schedules[4].start)
        self.assertEqual(22, scheduler.schedules[5].task_id)
        self.assertEqual(61, scheduler.schedules[5].start)
        self.assertEqual(33, scheduler.schedules[6].task_id)
        self.assertEqual(2, scheduler.schedules[6].start)
        self.assertEqual(33, scheduler.schedules[7].task_id)
        self.assertEqual(40, scheduler.schedules[7].start)
        self.assertEqual(33, scheduler.schedules[8].task_id)
        self.assertEqual(80, scheduler.schedules[8].start)
        self.assertEqual(44, scheduler.schedules[9].task_id)
        self.assertEqual(3, scheduler.schedules[9].start)
        self.assertEqual(44, scheduler.schedules[10].task_id)
        self.assertEqual(24, scheduler.schedules[10].start)
        self.assertEqual(44, scheduler.schedules[11].task_id)
        self.assertEqual(48, scheduler.schedules[11].start)
        self.assertEqual(44, scheduler.schedules[12].task_id)
        self.assertEqual(72, scheduler.schedules[12].start)
        self.assertEqual(44, scheduler.schedules[13].task_id)
        self.assertEqual(96, scheduler.schedules[13].start)

        scheduler.add_new_task(task_5)
        scheduler.print_schedule()
        scheduler.print_table()
开发者ID:LonghaiCui,项目名称:NaradaMetrics_Scheduler,代码行数:50,代码来源:scheduler+copy.py

示例3: test_bug_201

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import print_schedule [as 别名]
    def test_bug_201(self):
        metric_1 = Metric(1, 60, [1, 2])
        metric_2 = Metric(2, 60, [1, 2])
        metrics = [metric_1, metric_2]
        #Throuhput
        task_1 = Task(1, '71.62.82.92', '70.62.55.250', 1, 3600, 1)
        #Route change
        task_2 = Task(2, '71.62.82.92', '70.62.55.250', 2, 1800, 1)
        #Throuhput
        task_3 = Task(3, '71.62.82.92', '76.209.75.242', 1, 3600, 1)
        #Route change
        task_4 = Task(4, '70.62.55.250', '76.209.75.242', 2, 3600, 1)
        #T
        task_5 = Task(5, '70.62.55.250', '76.209.75.242', 1, 3600, 1)
        #Tmetrics[mid].conflicts
        task_6 = Task(6, '76.209.75.242', '70.62.55.250', 1, 7200, 1)
        #Route change
        task_7 = Task(7, '76.209.75.242', '70.62.55.250', 2, 1800, 1)
        tasks = [task_1, task_2, task_3, task_4, task_5, task_6, task_7]
        scheduler = Scheduler(2, metrics)
        scheduler.add_tasks(tasks)
        scheduler.print_schedule()

        flag = 1
        for i in range(len(scheduler.schedules)):
            for j in range(len(scheduler.schedules)):
                if (scheduler.schedules[i].src == scheduler.schedules[j].src or scheduler.schedules[i].src ==
                    scheduler.schedules[j].dst
                    or scheduler.schedules[i].dst == scheduler.schedules[j].src or scheduler.schedules[i].dst ==
                    scheduler.schedules[j].dst):
                    mid = scheduler.schedules[i].metric_id
                    if scheduler.schedules[j].metric_id in metrics[mid - 1].conflicts and abs(
                                    scheduler.schedules[i].start - scheduler.schedules[j].start) < 60 \
                        and abs(scheduler.schedules[i].start - scheduler.schedules[j].start) != 0:
                        flag = 0
        self.assertEqual(1, flag)
开发者ID:LonghaiCui,项目名称:NaradaMetrics_Scheduler,代码行数:38,代码来源:tests.py

示例4: test_basic_schedule

# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import print_schedule [as 别名]
    def test_basic_schedule(self):
        #conflicts = {11: [11, 22], 22: [11, 22, 33], 33: [22, 33], 44: [], 55: [22], 66: []}
        metric_1 = Metric(11, 10, [11, 22])
        metric_2 = Metric(22, 10, [11, 22, 33])
        metric_3 = Metric(33, 5, [22, 33])
        metric_4 = Metric(44, 5, [])
        metrics = [metric_1, metric_2, metric_3, metric_4]
        #id, src, dst, metric_id, period, priority
        scheduler = Scheduler(4, metrics)
        task_1 = Task(1, u'200.0.0.1', u'200.0.0.2', 11, 60, 0)
        task_2 = Task(2, u'200.0.0.1', u'200.0.0.2', 22, 40, 1)
        task_3 = Task(3, u'200.0.0.1', u'200.0.0.2', 33, 20, 0)
        task_4 = Task(4, u'200.0.0.1', u'200.0.0.2', 44, 30, 1)
        tasks = [task_1, task_2, task_3, task_4]
        #table.print_table()
        scheduler.add_tasks(tasks)
        scheduler.print_schedule()
        #scheduler.schedules.
        for i in range(len(scheduler.schedules)):
            print(scheduler.schedules[i].metric_id, scheduler.schedules[i].src, scheduler.schedules[i].dst,
                  scheduler.schedules[i].start,
                  scheduler.schedules[i].duration, scheduler.schedules[i].period, scheduler.schedules[i].priority)
        self.assertEqual(11, scheduler.schedules[0].metric_id)
        self.assertEqual(0, scheduler.schedules[0].start)
        self.assertEqual(11, scheduler.schedules[1].metric_id)
        self.assertEqual(60, scheduler.schedules[1].start)
        self.assertEqual(22, scheduler.schedules[2].metric_id)
        self.assertEqual(10, scheduler.schedules[2].start)
        self.assertEqual(22, scheduler.schedules[3].metric_id)
        self.assertEqual(45, scheduler.schedules[3].start)
        self.assertEqual(22, scheduler.schedules[4].metric_id)
        self.assertEqual(85, scheduler.schedules[4].start)
        self.assertEqual(33, scheduler.schedules[5].metric_id)
        self.assertEqual(0, scheduler.schedules[5].start)
        self.assertEqual(33, scheduler.schedules[6].metric_id)
        self.assertEqual(20, scheduler.schedules[6].start)
        self.assertEqual(33, scheduler.schedules[7].metric_id)
        self.assertEqual(40, scheduler.schedules[7].start)
        self.assertEqual(33, scheduler.schedules[8].metric_id)
        self.assertEqual(60, scheduler.schedules[8].start)
        self.assertEqual(33, scheduler.schedules[9].metric_id)
        self.assertEqual(80, scheduler.schedules[9].start)
        self.assertEqual(33, scheduler.schedules[10].metric_id)
        self.assertEqual(100, scheduler.schedules[10].start)
        self.assertEqual(44, scheduler.schedules[11].metric_id)
        self.assertEqual(0, scheduler.schedules[11].start)
        self.assertEqual(44, scheduler.schedules[12].metric_id)
        self.assertEqual(30, scheduler.schedules[12].start)
        self.assertEqual(44, scheduler.schedules[13].metric_id)
        self.assertEqual(60, scheduler.schedules[13].start)
        self.assertEqual(44, scheduler.schedules[14].metric_id)
        self.assertEqual(90, scheduler.schedules[14].start)
        #self.assertEqual(11,scheduler.schedules[0].metric_id)




            # # #TODO Priority not correct
    # def test_basic_schedule(self):
    #     #conflicts = {11: [11, 22], 22: [11, 22, 33], 33: [22, 33], 44: [], 55: [22], 66: []}
    #     metric_1 = Metric(11, 10, [11, 22])
    #     metric_2 = Metric(22, 10, [11, 22, 33])
    #     metric_3 = Metric(33, 5, [22, 33])
    #     metric_4 = Metric(44, 5, [])
    #     metrics = [metric_1, metric_2, metric_3, metric_4]
    #     #id, src, dst, metric_id, period, priority
    #     scheduler = Scheduler(4, metrics)
    #     task_1 = Task(1, u'200.0.0.1', u'200.0.0.2', 11, 60, 1)
    #     task_2 = Task(2, u'200.0.0.1', u'200.0.0.2', 22, 40, 1)
    #     task_3 = Task(3, u'200.0.0.1', u'200.0.0.2', 33, 20, 10)
    #     task_4 = Task(4, u'200.0.0.1', u'200.0.0.2', 44, 30, 1)
    #     tasks = [task_1, task_2, task_3, task_4]
    #
    #     scheduler.add_tasks(tasks)
    #     scheduler.print_schedule()
    #     for i in range(len(scheduler.schedules)):
    #         print(scheduler.schedules[i].metric_id, scheduler.schedules[i].src, scheduler.schedules[i].dst,
    #               scheduler.schedules[i].start,
    #               scheduler.schedules[i].duration, scheduler.schedules[i].period, scheduler.schedules[i].priority)
    #     self.assertEqual(11, scheduler.schedules[0].metric_id)
    #     self.assertEqual(0, scheduler.schedules[0].start)
    #     self.assertEqual(11, scheduler.schedules[1].metric_id)
    #     self.assertEqual(60, scheduler.schedules[1].start)
    #     self.assertEqual(22, scheduler.schedules[2].metric_id)
    #     self.assertEqual(10, scheduler.schedules[2].start)
    #     self.assertEqual(22, scheduler.schedules[3].metric_id)
    #     self.assertEqual(45, scheduler.schedules[3].start)
    #     self.assertEqual(22, scheduler.schedules[4].metric_id)
    #     self.assertEqual(85, scheduler.schedules[4].start)
    #     self.assertEqual(33, scheduler.schedules[5].metric_id)
    #     self.assertEqual(0, scheduler.schedules[5].start)
    #     self.assertEqual(33, scheduler.schedules[6].metric_id)
    #     self.assertEqual(20, scheduler.schedules[6].start)
    #     self.assertEqual(33, scheduler.schedules[7].metric_id)
    #     self.assertEqual(40, scheduler.schedules[7].start)
    #     self.assertEqual(33, scheduler.schedules[8].metric_id)
    #     self.assertEqual(60, scheduler.schedules[8].start)
    #     self.assertEqual(33, scheduler.schedules[9].metric_id)
    #     self.assertEqual(80, scheduler.schedules[9].start)
    #     self.assertEqual(33, scheduler.schedules[10].metric_id)
#.........这里部分代码省略.........
开发者ID:LonghaiCui,项目名称:NaradaMetrics_Scheduler,代码行数:103,代码来源:scheduler+copy.py


注:本文中的scheduler.Scheduler.print_schedule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。