本文整理汇总了Python中simulator.Simulator.executeSSTF方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.executeSSTF方法的具体用法?Python Simulator.executeSSTF怎么用?Python Simulator.executeSSTF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulator.Simulator
的用法示例。
在下文中一共展示了Simulator.executeSSTF方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSimulatorNoPageFaults
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import executeSSTF [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)
示例2: testSimulator
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import executeSSTF [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)