<s> '''<STR_LIT>''' <EOL> import os <EOL> import eventlet <EOL> import benchmarks <EOL> DATA_DIR = '<STR_LIT>' <EOL> if not os . path . exists ( DATA_DIR ) : <EOL> os . makedirs ( DATA_DIR ) <EOL> def write_result ( filename , best ) : <EOL> fd = open ( os . path . join ( DATA_DIR , filename ) , '<STR_LIT:w>' ) <EOL> fd . write ( '<STR_LIT>' % best ) <EOL> fd . close ( ) <EOL> def cleanup ( ) : <EOL> eventlet . sleep ( <NUM_LIT> ) <EOL> iters = <NUM_LIT> <EOL> best = benchmarks . measure_best ( <EOL> <NUM_LIT:5> , iters , <EOL> '<STR_LIT>' , <EOL> cleanup , <EOL> eventlet . sleep ) <EOL> write_result ( '<STR_LIT>' , best [ eventlet . sleep ] ) <EOL> gt = eventlet . spawn ( <EOL> benchmarks . measure_best , <NUM_LIT:5> , iters , <EOL> '<STR_LIT>' , <EOL> cleanup , <EOL> eventlet . sleep ) <EOL> best = gt . wait ( ) <EOL> write_result ( '<STR_LIT>' , best [ eventlet . sleep ] ) <EOL> def dummy ( i = None ) : <EOL> return i <EOL> def run_spawn ( ) : <EOL> eventlet . spawn ( dummy , <NUM_LIT:1> ) <EOL> def run_spawn_n ( ) : <EOL> eventlet . spawn_n ( dummy , <NUM_LIT:1> ) <EOL> def run_spawn_n_kw ( ) : <EOL> eventlet . spawn_n ( dummy , i = <NUM_LIT:1> ) <EOL> best = benchmarks . measure_best ( <EOL> <NUM_LIT:5> , iters , <EOL> '<STR_LIT>' , <EOL> cleanup , <EOL> run_spawn_n , <EOL> run_spawn , <EOL> run_spawn_n_kw ) <EOL> write_result ( '<STR_LIT>' , best [ run_spawn ] ) <EOL> write_result ( '<STR_LIT>' , best [ run_spawn_n ] ) <EOL> write_result ( '<STR_LIT>' , best [ run_spawn_n_kw ] ) <EOL> pool = None <EOL> def setup ( ) : <EOL> global pool <EOL> pool = eventlet . GreenPool ( iters ) <EOL> def run_pool_spawn ( ) : <EOL> pool . spawn ( dummy , <NUM_LIT:1> ) <EOL> def run_pool_spawn_n ( ) : <EOL> pool . spawn_n ( dummy , <NUM_LIT:1> ) <EOL> def cleanup_pool ( ) : <EOL> pool . waitall ( ) <EOL> best = benchmarks . measure_best ( <EOL> <NUM_LIT:3> , iters , <EOL> setup , <EOL> cleanup_pool , <EOL> run_pool_spawn , <EOL> run_pool_spawn_n , <EOL> ) <EOL> write_result ( '<STR_LIT>' , best [ run_pool_spawn ] ) <EOL> write_result ( '<STR_LIT>' , best [ run_pool_spawn_n ] ) </s>
