Exemplo n.º 1
0
 def test_cputime5(self):
     rm = taskrun.ResourceManager(taskrun.CpuTimeResource('time', 20))
     ob = OrderCheckObserver(['@t1', '+t1', '-t1'], verbose=False)
     tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])
     t1 = taskrun.FunctionTask(tm, 't1', myfunc, 'jimbo', 5)
     tm.run_tasks()
     self.assertTrue(ob.ok())
Exemplo n.º 2
0
def main(args):
    lock = threading.Lock()
    results = {}

    if args.verbose and args.cores > 1:
        print('verbose mode forces cores to 1')
        args.cores = 1
    if args.verbose:
        print('using {0} cores for execution'.format(args.cores))

    rm = taskrun.ResourceManager(
        taskrun.CounterResource('cores', 1, args.cores))
    tm = taskrun.TaskManager(resource_manager=rm, observers=[])

    for radix in range(args.minradix, args.maxradix + 1, 1):
        task = taskrun.FunctionTask(tm, 'radix_{0}'.format(radix),
                                    largestNetwork, args.hyperxsearch, radix,
                                    args.minbandwidth, None,
                                    args.maxdimensions, args.minconcentration,
                                    args.maxconcentration, lock, results,
                                    args.verbose)
        task.priority = radix

    tm.run_tasks()

    grid = []
    grid.append([
        '#', 'Dimensions', 'Widths', 'Weights', 'Concentration', 'Terminals',
        'Routers', 'Radix', 'Channels', 'Bisections', 'Cost'
    ])
    for radix in range(args.minradix, args.maxradix + 1, 1):
        grid.append(results[radix])
    print(search_util.makeGrid(grid))
Exemplo n.º 3
0
 def test_cputime7(self):
     rm = taskrun.ResourceManager(taskrun.CpuTimeResource('time', 20))
     tm = taskrun.TaskManager(rm)
     t1 = taskrun.FunctionTask(tm, 't1', myfunc, 'jimbo', 5)
     t1.resources = {'time': 20}
     error = False
     try:
         tm.run_tasks()
     except AssertionError:
         error = True
     self.assertTrue(error)
    def test_noexec(self):
        global total
        global thres
        total = 0
        thres = 0
        rm = taskrun.ResourceManager(taskrun.CounterResource('slot', 1, 1))
        ob = OrderCheckObserver(
            ['@t1', '@t2', '@t3', '@t4', '*t1', '*t2', '*t3', '*t4'])
        tm = taskrun.TaskManager(resource_manager=rm, observers=[ob])

        t1 = taskrun.FunctionTask(tm, 't1', myfunc, 'jimbo', 5)
        t1.add_condition(taskrun.FunctionCondition(cond))
        t2 = taskrun.FunctionTask(tm, 't2', myfunc, 'gertrude', 6)
        t2.add_condition(taskrun.FunctionCondition(cond))
        t3 = taskrun.FunctionTask(tm, 't3', myfunc, 'sally', 2)
        t3.add_condition(taskrun.FunctionCondition(cond))
        t4 = taskrun.FunctionTask(tm, 't4', myfunc, 'william', 3)
        t4.add_condition(taskrun.FunctionCondition(cond))

        tm.run_tasks()
        self.assertTrue(ob.ok())
        self.assertEqual(total, 0)
Exemplo n.º 5
0
print('setup time: {0:.3f}s'.format(elapsed))

start = time.clock()
tm.run_tasks()
stop = time.clock()
elapsed = stop - start
print('tasks per second: {0:.3f}'.format(num / elapsed))

# Function task
print('\n*** FunctionTask ***')
start = time.clock()
for idx in range(num):
    taskrun.FunctionTask(tm,
                         'Task_{0:04d}'.format(idx),
                         func,
                         'you',
                         'me',
                         'yall',
                         mom=True,
                         dad=False)
stop = time.clock()
elapsed = stop - start
print('setup time: {0:.3f}s'.format(elapsed))

start = time.clock()
tm.run_tasks()
stop = time.clock()
elapsed = stop - start
print('tasks per second: {0:.3f}'.format(num / elapsed))

# Nop task
print('\n*** NopTask ***')