<s> import sys <EOL> import threading <EOL> import time <EOL> from os . path import dirname <EOL> from codec_bench import Bench <EOL> sys . path . append ( dirname ( dirname ( __file__ ) ) ) <EOL> THREAD_COUNT = <NUM_LIT:2> <EOL> ENTRY_COUNT = <NUM_LIT:10> * <NUM_LIT:1000> <EOL> VALUE_SIZE = <NUM_LIT> <EOL> def do_benchmark ( ) : <EOL> class ClientThread ( threading . Thread ) : <EOL> def __init__ ( self , name ) : <EOL> threading . Thread . __init__ ( self , name = name ) <EOL> self . ops = <NUM_LIT:0> <EOL> self . decode = <NUM_LIT:0> <EOL> self . setDaemon ( True ) <EOL> self . bench = Bench ( ) <EOL> def run ( self ) : <EOL> while True : <EOL> self . bench . encode ( ) <EOL> self . bench . decode ( ) <EOL> self . ops += <NUM_LIT:1> <EOL> threads = [ ClientThread ( "<STR_LIT>" % i ) for i in xrange ( <NUM_LIT:0> , THREAD_COUNT ) ] <EOL> for t in threads : <EOL> t . start ( ) <EOL> start = time . time ( ) <EOL> counter = <NUM_LIT:1> <EOL> while counter < <NUM_LIT:10> : <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> print "<STR_LIT>" + str ( sum ( [ t . ops for t in threads ] ) / ( time . time ( ) - start ) ) <EOL> counter += <NUM_LIT:1> <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> do_benchmark ( ) </s>
