-í
è¶<c       sF  d  Z  d Z d k l Z d Z e d d ƒ \ Z Z Z Z	 Z
 d f  d „  ƒ  YZ d Z d Z d	 „  Z e d
 „ Z d a e a d a d a d g d a e d „  t g d ƒ a e a e a e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% e& d j o e ƒ  n d S(   sâ  
"PYSTONE" Benchmark Program

Version:        Python/1.1 (corresponds to C/1.1 plus 2 Pystone fixes)

Author:         Reinhold P. Weicker,  CACM Vol 27, No 10, 10/84 pg. 1013.

                Translated from ADA to C by Rick Richardson.
                Every method to preserve ADA-likeness has been used,
                at the expense of C-ness.

                Translated from C to Python by Guido van Rossum.

Version History:

                Version 1.1 corrects two bugs in version 1.0:

                First, it leaked memory: in Proc1(), NextRecord ends
                up having a pointer to itself.  I have corrected this
                by zapping NextRecord.PtrComp at the end of Proc1().

                Second, Proc3() used the operator != to compare a
                record to None.  This is rather inefficient and not
                true to the intention of the original benchmark (where
                a pointer comparison to None is intended; the !=
                operator attempts to find a method __cmp__ to do value
                comparison of the record).  Version 1.1 runs 5-10
                percent faster than version 1.0, so benchmark figures
                of different versions can't be compared directly.

i'  (   s   clocks   1.1i   i   s   Recordc      s)   t  Z e d d d d d „ Z d „  Z RS(   Ni    c    s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   s   PtrComps   selfs   Discrs   EnumComps   IntComps
   StringComp(   s   selfs   PtrComps   Discrs   EnumComps   IntComps
   StringComp(    (    s"   /usr/lib/python2.2/test/pystone.pys   __init__- s
    				c    s)   t  |  i |  i |  i |  i |  i ƒ Sd  S(   N(   s   Records   selfs   PtrComps   Discrs   EnumComps   IntComps
   StringComp(   s   self(    (    s"   /usr/lib/python2.2/test/pystone.pys   copy5 s    (   s   __name__s
   __module__s   Nones   __init__s   copy(    (    (    s"   /usr/lib/python2.2/test/pystone.pys   Record+ s   i    c     s.   t  ƒ  \ } }  d t t | f GHd |  GHd  S(   Ns#   Pystone(%s) time for %d passes = %gs-   This machine benchmarks at %g pystones/second(   s   pystoness	   benchtimes   stoness   __version__s   LOOPS(   s   stoness	   benchtime(    (    s"   /usr/lib/python2.2/test/pystone.pys   main< s    c    s   t  |  ƒ Sd  S(   N(   s   Proc0s   loops(   s   loops(    (    s"   /usr/lib/python2.2/test/pystone.pys   pystonesC s    s    i3   c    s   |  S(   N(   s   x(   s   x(    (    s"   /usr/lib/python2.2/test/pystone.pys   <lambda>K s    c    sİ  t  ƒ  }
 x t |  ƒ D] } q Wt  ƒ  |
 } t ƒ  a t ƒ  a t t _	 t
 t _ t t _ d t _ d t _ d } d t d d <t  ƒ  }
 x.t |  ƒ D] } t ƒ  t ƒ  d } d } d	 } t } t | | ƒ a x9 | | j  o+ d
 | | } t | | ƒ } | d } qÕ Wt t t | | ƒ t t ƒ a d } xN | t! j o@ | t" | d ƒ j o t# t
 ƒ } n t$ t% | ƒ d ƒ } q6W| | } | | } d | | | } t& | ƒ } q– Wt  ƒ  |
 | }	 |	 |  |	 f Sd  S(   Ni(   s   DHRYSTONE PROGRAM, SOME STRINGs   DHRYSTONE PROGRAM, 1'ST STRINGi
   i   i   i   i   s   DHRYSTONE PROGRAM, 2'ND STRINGi   i   s   As   C((   s   clocks	   starttimes   ranges   loopss   is   nulltimes   Records
   PtrGlbNexts   PtrGlbs   PtrComps   Ident1s   Discrs   Ident3s   EnumComps   IntComps
   StringComps
   String1Locs
   Array2Globs   Proc5s   Proc4s   IntLoc1s   IntLoc2s
   String2Locs   Ident2s   EnumLocs   Func2s   BoolGlobs   IntLoc3s   Proc7s   Proc8s
   Array1Globs   Proc1s	   CharIndexs	   Char2Globs   Func1s   Proc6s   chrs   ords   Proc2s	   benchtime(   s   loopss
   String1Locs   IntLoc2s   IntLoc1s
   String2Locs   IntLoc3s   EnumLocs	   CharIndexs   is	   benchtimes	   starttimes   nulltime(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc0O sf            	 								   

c    s³   t  i ƒ  |  _ } d |  _ |  i | _ |  i | _ t | i ƒ | _ | i t j o@ d | _ t	 |  i
 ƒ | _
 t  i | _ t | i d ƒ | _ n | i ƒ  }  t | _ |  Sd  S(   Ni   i   i
   (   s   PtrGlbs   copys   PtrParIns   PtrComps
   NextRecords   IntComps   Proc3s   Discrs   Ident1s   Proc6s   EnumComps   Proc7s   None(   s   PtrParIns
   NextRecord(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc1… s    			c    s^   |  d } xI d oA t d j o | d } | t }  t } n | t j o Pn q W|  Sd  S(   Ni
   i   s   A(   s   IntParIOs   IntLocs	   Char1Globs   IntGlobs   Ident1s   EnumLoc(   s   IntParIOs   EnumLocs   IntLoc(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc2• s    
 



c    s:   t  t j	 o t  i }  n d a t d t ƒ t  _ |  Sd  S(   Nid   i
   (   s   PtrGlbs   Nones   PtrComps	   PtrParOuts   IntGlobs   Proc7s   IntComp(   s	   PtrParOut(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc3  s     c     s#   t  d j }  |  p t }  d a d  S(   Ns   As   B(   s	   Char1Globs   BoolLocs   BoolGlobs	   Char2Glob(   s   BoolLoc(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc4ª s     c      s   d a  t a d  S(   Ns   A(   s	   Char1Globs   FALSEs   BoolGlob(    (    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc5± s      c    sª   |  } t |  ƒ o
 t } n |  t j o
 t } nn |  t j o! t d j o
 t } n t } n@ |  t j o
 t } n) |  t j o n |  t j o
 t } n | Sd  S(   Nid   (	   s	   EnumParIns
   EnumParOuts   Func3s   Ident4s   Ident1s   Ident2s   IntGlobs   Ident3s   Ident5(   s	   EnumParIns
   EnumParOut(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc6¸ s     





c    s   |  d } | | } | Sd  S(   Ni   (   s   IntParI1s   IntLocs   IntParI2s	   IntParOut(   s   IntParI1s   IntParI2s	   IntParOuts   IntLoc(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc7Ë s    

c    s¢   | d } | |  | <|  | |  | d <| |  | d <x) t | | d ƒ D] } | | | | <qH W| | | d d | | | d <|  | | | d | <d a d  S(   Ni   i   i   i   i   (   s   IntParI1s   IntLocs   IntParI2s	   Array1Pars   ranges   IntIndexs	   Array2Pars   IntGlob(   s	   Array1Pars	   Array2Pars   IntParI1s   IntParI2s   IntLocs   IntIndex(    (    s"   /usr/lib/python2.2/test/pystone.pys   Proc8Ğ s     

 "c    s)   |  } | } | | j o t Sn t Sd  S(   N(   s   CharPar1s   CharLoc1s   CharLoc2s   CharPar2s   Ident1s   Ident2(   s   CharPar1s   CharPar2s   CharLoc2s   CharLoc1(    (    s"   /usr/lib/python2.2/test/pystone.pys   Func1İ s
    c    s±   d } xH | d j o: t |  | | | d ƒ t j o d } | d } n q	 W| d j o
 | d j o
 d } n | d j o t Sn$ |  | j o | d } t Sn t Sd  S(   Ni   s   As   Ws   Zi   s   X(   s   IntLocs   Func1s   StrParI1s   StrParI2s   Ident1s   CharLocs   TRUEs   FALSE(   s   StrParI1s   StrParI2s   CharLocs   IntLoc(    (    s"   /usr/lib/python2.2/test/pystone.pys   Func2å s     "

c    s#   |  } | t j o t Sn t Sd  S(   N(   s	   EnumParIns   EnumLocs   Ident3s   TRUEs   FALSE(   s	   EnumParIns   EnumLoc(    (    s"   /usr/lib/python2.2/test/pystone.pys   Func3ö s     s   __main__N('   s   __doc__s   LOOPSs   times   clocks   __version__s   ranges   Ident1s   Ident2s   Ident3s   Ident4s   Ident5s   Records   TRUEs   FALSEs   mains   pystoness   IntGlobs   BoolGlobs	   Char1Globs	   Char2Globs
   Array1Globs   maps
   Array2Globs   Nones   PtrGlbs
   PtrGlbNexts   Proc0s   Proc1s   Proc2s   Proc3s   Proc4s   Proc5s   Proc6s   Proc7s   Proc8s   Func1s   Func2s   Func3s   __name__(   s   pystoness   Proc6s   Func2s   Proc5s   Records   TRUEs   __version__s   Ident4s   Ident5s   Func1s   FALSEs   Ident1s   Ident2s   Ident3s   clocks   Func3s   Proc8s   LOOPSs   Proc4s   Proc7s   mains   Proc1s   Proc0s   Proc3s   Proc2(    (    s"   /usr/lib/python2.2/test/pystone.pys   ?! s>   	6			
								