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


Python Simulator.executeLOOK方法代码示例

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


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

示例1: testSimulatorNoPageFaults

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import executeLOOK [as 别名]
class testSimulatorNoPageFaults(unittest.TestCase):
    """Tests default algorithms without page faults."""

    def setUp(self):
         self.simulator = Simulator()
         self.simulator.init_pos = 0
         self.simulator.requirements = [5, 15, 40, 65, 20, 35, 400, 90, 100]

    def test_FCFS(self):
        base_results = (([[], [0, 5, 15, 40, 65, 20, 35, 400, 90, 100]], 810, True), 'FCFS')
        self.assertEqual(self.simulator.executeFCFS(), base_results)
        
        self.simulator.init_pos = self.simulator.max_tracks
        base_results = (([[], [511, 5, 15, 40, 65, 20, 35, 400, 90, 100]], 1311, True), 'FCFS')
        self.assertEqual(self.simulator.executeFCFS(), base_results)

    def test_SSTF(self):
        base_results = (([[], [0, 5, 15, 20, 35, 40, 65, 90, 100, 400]], 400, True), 'SSTF')
        self.assertEqual(self.simulator.executeSSTF(), base_results)
        
        self.simulator.init_pos = self.simulator.max_tracks
        base_results = (([[], [511, 400, 100, 90, 65, 40, 35, 20, 15, 5]], 506, False), 'SSTF')
        self.assertEqual(self.simulator.executeSSTF(), base_results)

    def test_SCAN(self):
        base_results = (([[], [0, 5, 15, 20, 35, 40, 65, 90, 100, 400]], 400, True), 'SCAN')
        self.assertEqual(self.simulator.executeSCAN(), base_results)
        
        self.simulator.init_pos = self.simulator.max_tracks
        base_results = (([[], [511, 400, 100, 90, 65, 40, 35, 20, 15, 5]], 506, False), 'SCAN')
        self.assertEqual(self.simulator.executeSCAN(), base_results)

    def test_CSCAN(self):
        base_results = (([[], [0, 5, 15, 20, 35, 40, 65, 90, 100, 400], []], 400, True), 'CSCAN')
        self.assertEqual(self.simulator.executeCSCAN(), base_results)
        
        self.simulator.init_pos = self.simulator.max_tracks
        base_results = (([[], [511], [0, 5, 15, 20, 35, 40, 65, 90, 100, 400]], 400, True), 'CSCAN')
        self.assertEqual(self.simulator.executeCSCAN(), base_results)

    def test_LOOK(self):
        base_results = (([[], [0, 5, 15, 20, 35, 40, 65, 90, 100, 400]], 400, True), 'LOOK')
        self.assertEqual(self.simulator.executeLOOK(), base_results)
        
        self.simulator.init_pos = self.simulator.max_tracks
        base_results = (([[], [511, 400, 100, 90, 65, 40, 35, 20, 15, 5]], 506, False), 'LOOK')
        self.assertEqual(self.simulator.executeLOOK(), base_results)

    def test_CLOOK(self):
        base_results = (([[], [0, 5, 15, 20, 35, 40, 65, 90, 100, 400], []], 400, True), 'CLOOK')
        self.assertEqual(self.simulator.executeCLOOK(), base_results)
        
        self.simulator.init_pos = self.simulator.max_tracks
        base_results = (([[], [self.simulator.max_tracks], [5, 15, 20, 35, 40, 65, 90, 100, 400]], 395, True), 'CLOOK')
        self.assertEqual(self.simulator.executeCLOOK(), base_results)
开发者ID:farfanoide,项目名称:simuladorHDD,代码行数:57,代码来源:tests.py

示例2: testSimulator

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import executeLOOK [as 别名]
class testSimulator(unittest.TestCase):
    """Tests default algorithms under various significant circumstances."""

    def setUp(self):
         self.simulator = Simulator()
         self.simulator.init_pos = 0
         self.simulator.requirements = [-5, 15, 40, 65, 20, -35, -400, 90, 100]

    def test_FCFS(self):
        base_results = (([[0, 5, 35, 400], [15, 40, 65, 20, 90, 100]], 960, True), 'FCFS')
        self.assertEqual(self.simulator.executeFCFS(), base_results)
        
        self.simulator.init_pos=self.simulator.max_tracks
        base_results = (([[511, 5, 35, 400], [15, 40, 65, 20, 90, 100]], 1461, True), 'FCFS')
        self.assertEqual(self.simulator.executeFCFS(), base_results)

    def test_SSTF(self):
        base_results = (([[0, 5, 35, 400], [100, 90, 65, 40, 20, 15]], 785, False), 'SSTF')
        self.assertEqual(self.simulator.executeSSTF(), base_results)

        self.simulator.init_pos=self.simulator.max_tracks
        base_results = (([[511, 5, 35, 400], [100, 90, 65, 40, 20, 15]], 1286, False), 'SSTF')
        self.assertEqual(self.simulator.executeSSTF(), base_results)
       

    def test_SCAN(self):
        base_results = (([[0, 5, 35, 400], [self.simulator.max_tracks, 100, 90, 65, 40, 20, 15]], 1007, False), 'SCAN')
        self.assertEqual(self.simulator.executeSCAN(), base_results)

        self.simulator.init_pos=self.simulator.max_tracks
        base_results = (([[self.simulator.max_tracks, 5, 35, 400], [self.simulator.max_tracks, 100, 90, 65, 40, 20, 15]], 1508, False), 'SCAN')
        self.assertEqual(self.simulator.executeSCAN(), base_results)

    def test_CSCAN(self):
        base_results = (([[0, 5, 35, 400], [self.simulator.max_tracks], [0, 15, 20, 40, 65, 90, 100]], 611, True), 'CSCAN')
        self.assertEqual(self.simulator.executeCSCAN(), base_results)

        self.simulator.init_pos=self.simulator.max_tracks
        base_results = (([[511, 5, 35, 400], [self.simulator.max_tracks], [0, 15, 20, 40, 65, 90, 100]], 1112, True), 'CSCAN')
        self.assertEqual(self.simulator.executeCSCAN(), base_results)

    def test_LOOK(self):
        base_results = (([[0, 5, 35, 400], [100, 90, 65, 40, 20, 15]], 485, False), 'LOOK')
        self.assertEqual(self.simulator.executeLOOK(), base_results)

    def test_CLOOK(self):
        base_results = (([[0, 5, 35, 400], [], [15, 20, 40, 65, 90, 100]], 485, True), 'CLOOK')
        self.assertEqual(self.simulator.executeCLOOK(), base_results)
开发者ID:farfanoide,项目名称:simuladorHDD,代码行数:50,代码来源:tests.py


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