@@ -98,6 +98,9 @@ def threaded(l, test_func, tcount=10):
9898 from timeit import Timer
9999 from functools import partial
100100
101+ repeat_count = 100000
102+ repeat_count_t = 1000
103+
101104 rlock , flock = ('RLock' , RLock ()), ('FLock' , FLock ())
102105 locks = []
103106 args = sys .argv [1 :]
@@ -108,18 +111,19 @@ def threaded(l, test_func, tcount=10):
108111 locks .append (rlock )
109112 if 'flock' in args :
110113 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 )
111117 assert locks , args
112118
113119 for name , lock in locks :
114120 print ('Testing %s' % name )
115- repeat_count = 100000
116121 print ("sequential (x%d):" % repeat_count )
117122 for function in functions :
118123 timer = Timer (partial (function , lock ))
119124 print ('%-25s: %.3f sec' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count ))))
120125
121- repeat_count = 1000
122- print ("threaded 10T (x%d):" % repeat_count )
126+ print ("threaded 10T (x%d):" % repeat_count_t )
123127 for function in functions :
124128 timer = Timer (partial (threaded , lock , function ))
125- print ('%-25s: %.3f sec' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count ))))
129+ print ('%-25s: %.3f sec' % (function .__name__ , max (timer .repeat (repeat = 4 , number = repeat_count_t ))))
0 commit comments