Пример #1
0
    def test_generator(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(list(g.tasks(max_tasks=10))), 10)
        self.assertLessEqual(len(list(g.tasks(max_util=10))), 100)

        ts1 = g.tasks(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.tasks(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(sum([t.utilization() for t in ts1]), 10, places=2)
        self.assertNotEqual(sum([t.utilization() for t in ts2]), 10)
Пример #2
0
    def test_task_system_creation(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(g.make_task_set(max_tasks=10)), 10)
        self.assertLessEqual(len((g.make_task_set(max_util=10))), 100)

        ts1 = g.make_task_set(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.make_task_set(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(ts1.utilization(), 10, places=2)
        # Not strictly impossible, but very unlikely
        self.assertNotEqual(ts2.utilization(), 10)
Пример #3
0
    def test_generator(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(list(g.tasks(max_tasks=10))), 10)
        self.assertLessEqual(len(list(g.tasks(max_util=10))), 100)

        ts1 = g.tasks(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.tasks(max_util=10, squeeze=False, time_conversion=ms2us)

        self.assertAlmostEqual(sum([t.utilization() for t in ts1]),
                               10,
                               places=2)
        self.assertNotEqual(sum([t.utilization() for t in ts2]), 10)
Пример #4
0
    def test_drawing_functions(self):
        f = tg.uniform_int(10, 100)
        self.assertTrue(type(f()) == int)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform(10, 100)
        self.assertTrue(type(f()) == float)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform_choice("abcdefg")
        self.assertTrue(type(f()) == str)
        self.assertTrue("a" <= f() <= "g")

        f = tg.exponential(0.1, 0.7, 0.4)
        self.assertTrue(type(f()) == float)
        self.assertTrue(0.1 <= f() <= 0.7)
Пример #5
0
    def test_drawing_functions(self):
        f = tg.uniform_int(10, 100)
        self.assertTrue(type(f()) == int)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform(10, 100)
        self.assertTrue(type(f()) == float)
        self.assertTrue(10 <= f() <= 100)

        f = tg.uniform_choice("abcdefg")
        self.assertTrue(type(f()) == str)
        self.assertTrue('a' <= f() <= 'g')

        f = tg.exponential(0.1, 0.7, 0.4)
        self.assertTrue(type(f()) == float)
        self.assertTrue(0.1 <= f() <= 0.7)
Пример #6
0
    def test_task_system_creation(self):
        periods = tg.uniform_int(10, 100)
        utils = tg.exponential(0.1, 0.9, 0.3)
        g = tg.TaskGenerator(periods, utils)

        self.assertEqual(len(g.make_task_set(max_tasks=10)), 10)
        self.assertLessEqual(len((g.make_task_set(max_util=10))), 100)

        ts1 = g.make_task_set(max_util=10, squeeze=True, time_conversion=ms2us)
        ts2 = g.make_task_set(max_util=10,
                              squeeze=False,
                              time_conversion=ms2us)

        self.assertAlmostEqual(ts1.utilization(), 10, places=2)
        # Not strictly impossible, but very unlikely
        self.assertNotEqual(ts2.utilization(), 10)
Пример #7
0
import re
import random
from functools import partial

import schedcat.generator.tasks as gen

def decode_params(name):
    # uni-UMIN-UMAX-PMIN-PMAX    
    # bimo-
    # exp-UMIN-UMAX-MEAN-PMIN-PMAX
    
    pass

NAMED_PERIODS = {
# Named period distributions used in several UNC papers, in milliseconds.
    'uni-short'     : gen.uniform_int( 3,  33),
    'uni-moderate'  : gen.uniform_int(10, 100),
    'uni-long'      : gen.uniform_int(50, 250),

    'log-uni-short'     : gen.log_uniform_int( 3,  33),
    'log-uni-moderate'  : gen.log_uniform_int(10, 100),
    'log-uni-long'      : gen.log_uniform_int(50, 250),
    }

NAMED_UTILIZATIONS = {
# Named utilization distributions used in several UNC papers, in milliseconds.
    'uni-light'     : gen.uniform(0.001, 0.1),
    'uni-medium'    : gen.uniform(0.1  , 0.4),
    'uni-heavy'     : gen.uniform(0.5  , 0.9),

    'exp-light'     : gen.exponential(0, 1, 0.10),
Пример #8
0
from functools import partial

import schedcat.generator.tasks as gen


def decode_params(name):
    # uni-UMIN-UMAX-PMIN-PMAX
    # bimo-
    # exp-UMIN-UMAX-MEAN-PMIN-PMAX

    pass


NAMED_PERIODS = {
    # Named period distributions used in several UNC papers, in milliseconds.
    'uni-short': gen.uniform_int(3, 33),
    'uni-moderate': gen.uniform_int(10, 100),
    'uni-long': gen.uniform_int(50, 250),
}

NAMED_UTILIZATIONS = {
    # Named utilization distributions used in several UNC papers, in milliseconds.
    'uni-light':
    gen.uniform(0.001, 0.1),
    'uni-medium':
    gen.uniform(0.1, 0.4),
    'uni-heavy':
    gen.uniform(0.5, 0.9),
    'exp-light':
    gen.exponential(0, 1, 0.10),
    'exp-medium':