@@ -101,29 +101,27 @@ def threaded(l, test_func, tcount=10):
101101 repeat_count = 100000
102102 repeat_count_t = 1000
103103
104- rlock , flock = ('RLock' , RLock ()), ('FLock ' , FLock ())
104+ rlock , flock = ('threading. RLock' , RLock ()), ('FastRLock ' , FLock ())
105105 locks = []
106106 args = sys .argv [1 :]
107- if not args :
107+ if 'rlock' in args :
108+ locks .append (rlock )
109+ if 'flock' in args :
110+ locks .append (flock )
111+ if not locks :
108112 locks = [rlock , flock ]
109- else :
110- if 'rlock' in args :
111- locks .append (rlock )
112- if 'flock' in args :
113- locks .append (flock )
114- for _ in range (args .count ('quick' )):
115- repeat_count = max (10 , repeat_count // 100 )
116- repeat_count_t = max (5 , repeat_count_t // 10 )
117- assert locks , args
113+ for _ in range (args .count ('quick' )):
114+ repeat_count = max (10 , repeat_count // 100 )
115+ repeat_count_t = max (5 , repeat_count_t // 10 )
118116
119117 for name , lock in locks :
120118 print ('Testing %s' % name )
121119 print ("sequential (x%d):" % repeat_count )
122120 for function in functions :
123121 timer = Timer (partial (function , lock ))
124- print ('%-25s: %.3f sec ' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count ))))
122+ print ('%-25s: %9.2f msec ' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count )) * 1000.0 ))
125123
126124 print ("threaded 10T (x%d):" % repeat_count_t )
127125 for function in functions :
128126 timer = Timer (partial (threaded , lock , function ))
129- print ('%-25s: %.3f sec ' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count_t ))))
127+ print ('%-25s: %9.2f msec ' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count_t )) * 1000.0 ))
0 commit comments