def run(param_file, problem): probInfos = problem.split('-') listSpecIndex = int(probInfos[0]) if len(probInfos) > 1: listLength = int(probInfos[1]) else: listLength = 4000 if len(probInfos) > 2: numberOfRepeat = int(probInfos[2]) else: numberOfRepeat = 1 if len(probInfos) > 3: groupSize = int(probInfos[3]) else: groupSize = 1 params = read_params_from_file(param_file) if int(params['nothing']) != 0: return {'TIME': float("inf")} coopTreeFactory = CooperationTreeFactory(name="test factory") try: treeEncodedNumber = int(params['coopTree']) except: treeEncodedNumber = int(float(params['coopTree'])) createTree = coopTreeFactory.createTreeFromEncodedNumber coopTree = createTree(name='coop tree', encodedNumber=treeEncodedNumber, radix=6) l = [] for g in range(groupSize): l.append(create_test_list(listSpecs[listSpecIndex], listLength, 0)) meanTime = 0.0 for r in range(numberOfRepeat): sortingTime = 0.0 for i in range(groupSize): l1 = list(l[i]) tb = benchmarkTime() try: l1 = coopsort(l1, coopTree.getRoot()) except: return {'TIME': float("inf")} te = benchmarkTime() sortingTime = sortingTime + (te - tb) del l1[:] del l1 meanTime = meanTime + sortingTime measures = {'TIME': meanTime / numberOfRepeat} return measures
def run(param_file, problem): probInfos = problem.split('-') listSpecIndex = int(probInfos[0]) if len(probInfos) > 1: listLength = int(probInfos[1]) else: listLength = 4000 if len(probInfos) > 2: numberOfRepeat = int(probInfos[2]) else: numberOfRepeat = 1 if len(probInfos) > 3: groupSize = int(probInfos[3]) else: groupSize = 1 params = read_params_from_file(param_file) if int(params['nothing']) != 0: return {'TIME': float("inf")} coopTreeFactory = CooperationTreeFactory(name="test factory") try: treeEncodedNumber = int(params['coopTree']) except: treeEncodedNumber = int(float(params['coopTree'])) createTree = coopTreeFactory.createTreeFromEncodedNumber coopTree = createTree(name='coop tree', encodedNumber=treeEncodedNumber, radix=6) l = [] for g in range(groupSize): l.append(create_test_list(listSpecs[listSpecIndex], listLength, 0)) meanTime = 0.0 for r in range(numberOfRepeat): sortingTime = 0.0 for i in range(groupSize): l1 = list(l[i]) tb = benchmarkTime() try: l1 = coopsort(l1, coopTree.getRoot()) except: return {'TIME': float("inf")} te = benchmarkTime() sortingTime = sortingTime + (te - tb) del l1[:] del l1 meanTime = meanTime + sortingTime measures = {'TIME': meanTime / numberOfRepeat} return measures
cpuTime = {} profiles = {} for name, coopTree in coopTrees.iteritems(): profiles[name] = [] for i in range(numberOfList): l = create_test_list(listSpec, listLength, 0) minTime = float('inf') cpuTime = {} for name, coopTree in coopTrees.iteritems(): meanTime = 0.0 for r in range(numberOfRepeat): l1 = list(l) if isfunction(coopTree): tb = benchmarkTime() l1 = coopTree(l1) else: tb = benchmarkTime() l1 = coopsort(l1, coopTree.getRoot()) te = benchmarkTime() del l1[:] del l1 meanTime = meanTime + (te - tb) meanTime = meanTime / numberOfRepeat cpuTime[name] = meanTime if (meanTime < minTime): minTime = meanTime for name, t in cpuTime.iteritems(): profiles[name].append(t / minTime)
numberOfRepeat = benchmarkSpec['testing']['repeats'] for listSpec in listSpecs: listType = str(listSpec) cpuTime[listType] = {} for name, coopTree in coopTrees.iteritems(): cpuTime[listType][name] = {} for k in range(numberOfList): n = listLengthUnit * (k + 1) l = create_test_list(listSpec, n, 0) for name, coopTree in coopTrees.iteritems(): meanTime = 0.0 for r in range(numberOfRepeat): l1 = list(l) if isfunction(coopTree): tb = benchmarkTime() l1 = coopTree(l1) else: tb = benchmarkTime() l1 = coopsort(l1, coopTree.getRoot()) te = benchmarkTime() listIsSorted = verify_sorted_list(l1) if listIsSorted: meanTime = meanTime + (te - tb) else: raise Exception("There is a problem with " + name) del l1[:] del l1 cpuTime[listType][name][n] = meanTime / numberOfRepeat print cpuTime