def funcMapScan(l): resultat = futures.mapScan(func4, operator.add, l) _control.execQueue.socket.pumpInfoSocket() return resultat
# """ This is an example usage of a mapScan function using SCOOP. """ from scoop import futures import operator from itertools import accumulate import time def manipulateData(inData): # Simulate a 10ms workload on every tasks time.sleep(0.01) return sum(inData) if __name__ == '__main__': scoopTime = time.time() res = futures.mapScan(manipulateData, operator.add, list([a] * a for a in range(10))) scoopTime = time.time() - scoopTime print("Executed parallely in: {0:.3f}s with result: {1}".format( scoopTime, res)) serialTime = time.time() res = list( accumulate(map(manipulateData, list([a] * a for a in range(10))))) serialTime = time.time() - serialTime print("Executed serially in: {0:.3f}s with result: {1}".format( serialTime, res))
from scoop import futures import operator from itertools import accumulate import time def manipulateData(inData): # Simulate a 10ms workload on every tasks time.sleep(0.01) return sum(inData) if __name__ == '__main__': scoopTime = time.time() res = futures.mapScan( manipulateData, operator.add, list([a] * a for a in range(10)) ) scoopTime = time.time() - scoopTime print("Executed parallely in: {0:.3f}s with result: {1}".format( scoopTime, res ) ) serialTime = time.time() res = list(accumulate(map(manipulateData, list([a] * a for a in range(10))))) serialTime = time.time() - serialTime print("Executed serially in: {0:.3f}s with result: {1}".format( serialTime, res