<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import time <EOL> import ipyparallel as ipp <EOL> rc = ipp . Client ( ) <EOL> dv = rc [ : ] <EOL> v = rc . load_balanced_view ( ) <EOL> dv . scatter ( '<STR_LIT:id>' , rc . ids , flatten = True ) <EOL> print ( "<STR_LIT>" , dv [ '<STR_LIT:id>' ] ) <EOL> ref = ipp . Reference ( '<STR_LIT:id>' ) <EOL> print ( "<STR_LIT>" ) <EOL> tic = time . time ( ) <EOL> ar = dv . apply ( time . sleep , ref ) <EOL> for i , r in enumerate ( ar ) : <EOL> print ( "<STR_LIT>" % ( i , time . time ( ) - tic ) ) <EOL> def sleep_here ( t ) : <EOL> import time <EOL> time . sleep ( t ) <EOL> return id , t <EOL> print ( "<STR_LIT>" ) <EOL> amr = v . map ( sleep_here , [ <NUM_LIT> * t for t in range ( <NUM_LIT:100> ) ] ) <EOL> tic = time . time ( ) <EOL> for i , r in enumerate ( amr ) : <EOL> print ( "<STR_LIT>" % ( i , r [ <NUM_LIT:0> ] , time . time ( ) - tic ) ) <EOL> print ( "<STR_LIT>" ) <EOL> amr = v . map ( sleep_here , [ <NUM_LIT> * t for t in range ( <NUM_LIT:100> ) ] , chunksize = <NUM_LIT:4> ) <EOL> tic = time . time ( ) <EOL> for i , r in enumerate ( amr ) : <EOL> print ( "<STR_LIT>" % ( i , r [ <NUM_LIT:0> ] , time . time ( ) - tic ) ) <EOL> print ( "<STR_LIT>" ) <EOL> amr = v . map ( sleep_here , [ <NUM_LIT> * t for t in range ( <NUM_LIT:100> , <NUM_LIT:0> , - <NUM_LIT:1> ) ] , ordered = False , chunksize = <NUM_LIT:2> ) <EOL> tic = time . time ( ) <EOL> for i , r in enumerate ( amr ) : <EOL> print ( "<STR_LIT>" % ( r [ <NUM_LIT:1> ] , r [ <NUM_LIT:0> ] , time . time ( ) - tic ) ) </s>
