コード例 #1
0
ファイル: engine.py プロジェクト: Estoque86/Icarus
def main():
    """Main function"""
    if len(argv) != 5:
        print('Usage: python simrun.py topology.xml eventschedule.xml name_scenario strategy')
        exit(1)
    # parse arguments
    topology = read_topology(argv[1])# parse from command line
    event_schedule = read_event_schedule(argv[2]) # parse from command line
    scenario_id = argv[3]
    strategy_id = argv[4]
    run(topology, event_schedule, scenario_id, strategy_id)
コード例 #2
0
 def test_read_write_event_schedule(self):
     action = ['read_email', 'watch_video']
     schedule = fnss.deterministic_process_event_schedule(20, 0, 801, 'ms',
                                                          self.event_gen,
                                                          0.5, action=action)
     time, event = schedule[2]
     tmp_es_file = path.join(TMP_DIR, 'event-schedule.xml')
     fnss.write_event_schedule(schedule, tmp_es_file)
     read_schedule = fnss.read_event_schedule(tmp_es_file)
     self.assertEqual(len(schedule), len(read_schedule))
     read_time, read_event = read_schedule[2]
     self.assertEqual(time, read_time)
     self.assertEqual(event, read_event)
コード例 #3
0
 def test_read_write_event_schedule(self):
     action = ['read_email', 'watch_video']
     schedule = fnss.deterministic_process_event_schedule(20, 0, 801, 'ms',
                                                          self.event_gen,
                                                          0.5, action=action)
     time, event = schedule[2]
     tmp_es_file = path.join(TMP_DIR, 'event-schedule.xml')
     fnss.write_event_schedule(schedule, tmp_es_file)
     read_schedule = fnss.read_event_schedule(tmp_es_file)
     self.assertEqual(len(schedule), len(read_schedule))
     read_time, read_event = read_schedule[2]
     self.assertEqual(time, read_time)
     self.assertEqual(event, read_event)
コード例 #4
0
 def test_read_write_event_schedule_special_type(self):
     schedule = fnss.EventSchedule()
     event = {'tuple_param': (1, 2, 3),
              'dict_param': {'a': 1, 'b': 2},
              'list_param':[1, 'hello', 0.3]}
     schedule.add(1, event)
     tmp_es_file = path.join(TMP_DIR, 'event-schedule-special.xml')
     fnss.write_event_schedule(schedule, tmp_es_file)
     read_schedule = fnss.read_event_schedule(tmp_es_file)
     self.assertEqual(len(schedule), len(read_schedule))
     _, read_event = read_schedule[0]
     self.assertEqual(event, read_event)
     self.assertEqual(tuple, type(read_event['tuple_param']))
     self.assertEqual(list, type(read_event['list_param']))
     self.assertEqual(dict, type(read_event['dict_param']))
     self.assertEqual(event['dict_param'], read_event['dict_param'])
     self.assertEqual(event['list_param'], read_event['list_param'])
     self.assertEqual(event['tuple_param'], read_event['tuple_param'])
コード例 #5
0
 def test_read_write_event_schedule_special_type(self):
     schedule = fnss.EventSchedule()
     event = {'tuple_param': (1, 2, 3),
              'dict_param': {'a': 1, 'b': 2},
              'list_param':[1, 'hello', 0.3]}
     schedule.add(1, event)
     tmp_es_file = path.join(TMP_DIR, 'event-schedule-special.xml')
     fnss.write_event_schedule(schedule, tmp_es_file)
     read_schedule = fnss.read_event_schedule(tmp_es_file)
     self.assertEqual(len(schedule), len(read_schedule))
     _, read_event = read_schedule[0]
     self.assertEqual(event, read_event)
     self.assertEqual(tuple, type(read_event['tuple_param']))
     self.assertEqual(list, type(read_event['list_param']))
     self.assertEqual(dict, type(read_event['dict_param']))
     self.assertEqual(event['dict_param'], read_event['dict_param'])
     self.assertEqual(event['list_param'], read_event['list_param'])
     self.assertEqual(event['tuple_param'], read_event['tuple_param'])
コード例 #6
0
ファイル: run.py プロジェクト: Estoque86/Icarus
def run_simulation_scenario(t, a, c, s):
    """Run a single simulation scenario with given topology, alpha, cache size
    and strategy
    """
    use_events_file = config.USE_EVENTS_FILE
    n_contents = config.N_CONTENTS
    scenarios_dir = config.SCENARIOS_DIR
    topo_prefix = config.TOPO_PREFIX
    es_prefix = config.ES_PREFIX
    
    topo_file = path.join(scenarios_dir, topo_prefix + 'T=%s@C=%s.xml' % (t, str(c)))
    scenario_id = 'T=%s@C=%s@A=%s@S=%s' % (t, str(c), str(a), s)
    topo = read_topology(topo_file)
    if use_events_file:
        es_file = path.join(scenarios_dir, es_prefix + 'T=%s@A=%s.xml' % (t, str(a)))
        es = read_event_schedule(es_file)
    else:
        es = req_generator(topo, n_contents, a)
    run(topo, es, scenario_id, s) 
コード例 #7
0
def run_simulation_scenario(t, a, c, s):
    """Run a single simulation scenario with given topology, alpha, cache size
    and strategy
    """
    use_events_file = config.USE_EVENTS_FILE
    n_contents = config.N_CONTENTS
    scenarios_dir = config.SCENARIOS_DIR
    topo_prefix = config.TOPO_PREFIX
    es_prefix = config.ES_PREFIX

    topo_file = path.join(scenarios_dir,
                          topo_prefix + 'T=%s@C=%s.xml' % (t, str(c)))
    scenario_id = 'T=%s@C=%s@A=%s@S=%s' % (t, str(c), str(a), s)
    topo = read_topology(topo_file)
    if use_events_file:
        es_file = path.join(scenarios_dir,
                            es_prefix + 'T=%s@A=%s.xml' % (t, str(a)))
        es = read_event_schedule(es_file)
    else:
        es = req_generator(topo, n_contents, a)
    exec_experiment(topo, es, scenario_id, s)