N
Èz7c       sª     d  Z    k Z  k Z  k l  k Z 
 d Z  e d  Z  d   Z  d   Z	 2 d   Z
 6 d   Z H e d j o I k Z J e e i  n d S(	   s/   
Tests the PQueue implementation a little bit.
i@ c    s     d G|  Gd G t   }  g  }  x5 t |   d  r" }  | i t i d |    q9 W t   }  d G| | Gd GH | Sd  S(   Ns
   Generatings   random numbers....i    s   done --s   seconds.(
   s   nums   clocks   starts   numberss   xranges   xs   appends   whrandoms   randints   stop(   s   nums   starts   numberss   xs   stops   benchmark.pys   generatenumbers s   	 	 c    sm     d G t    }  x2 | d  r% }  |  i | t   t    } q" W d G| | Gd GH d  Sd  S(   Ns%   Inserting into the priority queue....i    s   done --s   seconds.(   s   clocks   starts   numss   xs   pqs   inserts   Nones   stop(   s   pqs   numss   starts   xs   stops   benchmark.pys
   testinsert s    	c    sØ      d G! t    } " g  } # xM # d oB $ y % | i |  i   d  Wn & t j
 o & Pn Xq% W' t    } ( d G| | Gd GH* d G+ | } , | i
   - | | j o . d GHn	 0 d GHd  S(	   Ns&   Extracting from the priority queue....i   i    s   done --s   seconds.s   Checking the results....s   oooh... they look good.s   doh... they look screwed.(   s   clocks   starts   outs   appends   pqs   pops
   IndexErrors   stops   numss   copyns   sort(   s   pqs   numss   starts   outs   stops   copyns   benchmark.pys   testextract s"   	 
 
c    s'   2 3 t  |  |  4 t |  |  d  S(   N(   s
   testinserts   pqs   numss   testextract(   s   pqs   numss   benchmark.pys   testpq2 s   c    sÞ   6 7 t  |   d j oF 8 k } 9 y : | i |  d  } Wn ; t j
 o
 ; n Xn < t i   } = t	 |  } > d GH? t | |  A t i   } C | i | _ D | i | _ E d GHF t | |  d  S(   Ni   s   Testing pqueue.PQueue:s   Testing pq3.PQ0:(   s   lens   argvs   strings   atois	   benchsizes
   ValueErrors   pqueues   PQueues   ps   generatenumberss   numss   testpqs   pq3s   PQ0s   addelts   inserts
   poplargests   pop(   s   argvs   strings	   benchsizes   ps   numss   benchmark.pys   main6 s   	 s   __main__N(   s   __doc__s   pqueues   pq3s   times   clocks   whrandoms	   benchsizes   generatenumberss
   testinserts   testextracts   testpqs   mains   __name__s   syss   argv(    s   benchmark.pys   ? s   		
		
		