mς
­fIc           @   sι  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 e d	  Z e d
  Z d a e a d a d a d g d a e d   t g d  a d a d 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« d k' Z' d   Z( e) e' i*  d Z+ e+ d j o e( d e+  nZ e+ d j oF y e, e' i* d  Z- WqΧe. j
 o e( d e' i* d  qΧXn e Z- e 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.

iPΓ  (   s   clocks   1.1i   i   t   Recordc           B   s)   t  Z d  d d d d d  Z d   Z RS(   Ni    c         C   s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   PtrCompt   selft   Discrt   EnumCompt   IntCompt
   StringComp(   R   R   R   R   R   R   (    (    t)   /mit/python/lib/python2.4/test/pystone.pyt   __init__-   s
    				c         C   s%   t  |  i |  i |  i |  i |  i  S(   N(   R    R   R   R   R   R   R   (   R   (    (    R   t   copy5   s    (   t   __name__t
   __module__t   NoneR   R	   (    (    (    R   R    +   s   i    c         C   s1   t  |   \ } } d t |  | f GHd | GHd  S(   Ns#   Pystone(%s) time for %d passes = %gs-   This machine benchmarks at %g pystones/second(   t   pystonest   loopst	   benchtimet   stonest   __version__(   R   R   R   (    (    R   t   main<   s    c         C   s
   t  |   S(   N(   t   Proc0R   (   R   (    (    R   R   C   s    t    i3   c         C   s   |  S(   N(   t   x(   R   (    (    R   t   <lambda>K   s    c         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 S(   Ni(   s   DHRYSTONE PROGRAM, SOME STRINGs   DHRYSTONE PROGRAM, 1'ST STRINGi
   i   i   i   i   s   DHRYSTONE PROGRAM, 2'ND STRINGi   i   t   At   C((   t   clockt	   starttimet   rangeR   t   it   nulltimeR    t
   PtrGlbNextt   PtrGlbR   t   Ident1R   t   Ident3R   R   R   t
   String1Loct
   Array2Globt   Proc5t   Proc4t   IntLoc1t   IntLoc2t
   String2Loct   Ident2t   EnumLoct   Func2t   BoolGlobt   IntLoc3t   Proc7t   Proc8t
   Array1Globt   Proc1t	   CharIndext	   Char2Globt   Func1t   Proc6t   chrt   ordt   Proc2R   (   R   R"   R(   R-   R2   R   R   R'   R&   R*   R   R   (    (    R   R   O   sf            	 								   

c         C   s―   t  i   |  _ } d |  _ |  i | _ |  i | _ t | i  | _ | i t j o@ d | _ t	 |  i
  | _
 t  i | _ t | i d  | _ n | i   }  d  | _ |  S(   Ni   i   i
   (   R   R	   t   PtrParInR   t
   NextRecordR   t   Proc3R   R    R5   R   R.   R   (   R9   R:   (    (    R   R1      s    			c         C   sS   |  d } xB t d j o | d } | t }  t } n | t j o Pq q W|  S(   Ni
   i   R   (   t   IntParIOt   IntLoct	   Char1Globt   IntGlobR    R*   (   R<   R*   R=   (    (    R   R8      s    
  



c         C   s6   t  d  j	 o t  i }  n d a t d t  t  _ |  S(   Nid   i
   (   R   R   R   t	   PtrParOutR?   R.   R   (   R@   (    (    R   R;       s     c          C   s#   t  d j }  |  p t }  d a d  S(   NR   t   B(   R>   t   BoolLocR,   R3   (   RB   (    (    R   R%   ͺ   s     c           C   s   d a  t a d  S(   NR   (   R>   t   FALSER,   (    (    (    R   R$   ±   s      c         C   s₯   |  } t |   p
 t } n |  t j o
 t } nn |  t j o! t d j o
 t } q‘ t } n@ |  t j o
 t } n) |  t j o n |  t j o
 t } n | S(   Nid   (	   t	   EnumParInt
   EnumParOutt   Func3t   Ident4R    R)   R?   R!   t   Ident5(   RD   RE   (    (    R   R5   Έ   s     





c         C   s   |  d } | | } | S(   Ni   (   t   IntParI1R=   t   IntParI2t	   IntParOut(   RI   RJ   RK   R=   (    (    R   R.   Λ   s    

c         C   s’   | d } | |  | <|  | |  | d <| |  | d <x) t | | d  D] } | | | | <qH W| | | d d | | | d <|  | | | d | <d a d  S(   Ni   i   i   i   i   (   RI   R=   RJ   t	   Array1ParR   t   IntIndext	   Array2ParR?   (   RL   RN   RI   RJ   R=   RM   (    (    R   R/   Π   s     

 "c         C   s)   |  } | } | | j o t Sn t Sd  S(   N(   t   CharPar1t   CharLoc1t   CharLoc2t   CharPar2R    R)   (   RO   RR   RQ   RP   (    (    R   R4   έ   s
    c         C   s±   d } xH | d j o: t |  | | | d  t j o d } | d } q	 q	 W| d j o | d j o
 d } n | d j o t Sn$ |  | j o | d } t Sn t Sd  S(   Ni   R   t   Wt   Zi   t   X(   R=   R4   t   StrParI1t   StrParI2R    t   CharLoct   TRUERC   (   RV   RW   RX   R=   (    (    R   R+   ε   s     "

c         C   s   |  } | t j o t Sn t S(   N(   RD   R*   R!   RY   RC   (   RD   R*   (    (    R   RF   φ   s     t   __main__Nc         C   s6   t  i |  It  i d t  i d IJt  i d  d  S(   Ns   usage: %s [number_of_loops]i    id   (   t   syst   stderrt   msgt   argvt   exit(   R]   (    (    R   t   errorύ   s    s   %d arguments are too many;s   Invalid argument %r;(/   t   __doc__t   LOOPSt   timeR   R   R   R    R)   R!   RG   RH   R    RY   RC   R   R   R?   R,   R>   R3   R0   t   mapR#   R   R   R   R   R1   R8   R;   R%   R$   R5   R.   R/   R4   R+   RF   R
   R[   R`   t   lenR^   t   nargst   intR   t
   ValueError(   R   RY   RF   R+   R4   R   Rb   R   R/   R   Rf   R[   R    RG   RH   R   RC   R    R)   R!   R`   R$   R%   R.   R5   R1   R   R;   R8   (    (    R   t   ?!   sT   6			
										 