[Python-checkins] CVS: python/dist/src/Lib/test test_threading.py,1.1,1.2

Tim Peters tim_one@users.sourceforge.net
Mon, 20 Aug 2001 14:45:21 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv27959

Modified Files:
	test_threading.py 
Log Message:
Test failed because these was no expected-output file, but always printed
to stdout.  Repaired by not printing at all except in verbose mode.

Made the test about 6x faster -- envelope analysis showed it took time
proportional to the square of the # of tasks.  Now it's linear.


Index: test_threading.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threading.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_threading.py	2001/08/20 20:28:48	1.1
--- test_threading.py	2001/08/20 21:45:19	1.2
***************
*** 8,11 ****
--- 8,13 ----
  import time
  
+ # This takes about n/3 seconds to run (about n/3 clumps of tasks, times
+ # about 1 second per clump).
  numtasks = 10
  
***************
*** 18,24 ****
      def run(self):
          global running
!         delay = random.random() * numtasks
          if verbose:
!             print 'task', self.getName(), 'will run for', round(delay, 1), 'sec'
          sema.acquire()
          mutex.acquire()
--- 20,26 ----
      def run(self):
          global running
!         delay = random.random() * 2
          if verbose:
!             print 'task', self.getName(), 'will run for', delay, 'sec'
          sema.acquire()
          mutex.acquire()
***************
*** 46,52 ****
  starttasks()
  
! print 'waiting for all tasks to complete'
  for t in threads:
      t.join()
! print 'all tasks done'
! 
--- 48,55 ----
  starttasks()
  
! if verbose:
!     print 'waiting for all tasks to complete'
  for t in threads:
      t.join()
! if verbose:
!     print 'all tasks done'