ó
	Q˜[c           @  s  d  Z  d d l m Z d d l m Z d Z d Z e d d ƒ \ Z Z	 Z
 Z Z d e 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 g  t g d D] Z e ^ q½ 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 k rþd d l* Z* d „  Z+ e, e* j- ƒ d Z. e. d k rœe+ d e. ƒ nU e. d k rëy e/ e* j- d ƒ Z0 Wqñe1 k
 rçe+ d e* j- d ƒ qñXn e Z0 e e0 ƒ 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ÿÿÿÿ(   t   print_function(   t   clockiPÃ  s   1.1i   i   t   Recordc           B  s)   e  Z d d  d  d  d  d „ Z d „  Z RS(   i    c         C  s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   PtrCompt   Discrt   EnumCompt   IntCompt
   StringComp(   t   selfR   R   R   R   R   (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyt   __init__/   s
    				c         C  s%   t  |  j |  j |  j |  j |  j ƒ S(   N(   R   R   R   R   R   R   (   R   (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyt   copy7   s    N(   t   __name__t
   __module__t   NoneR	   R
   (    (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR   -   s   	i    c         C  s;   t  |  ƒ \ } } t d t |  | f ƒ t d | ƒ d  S(   Ns#   Pystone(%s) time for %d passes = %gs-   This machine benchmarks at %g pystones/second(   t   pystonest   printt   __version__(   t   loopst	   benchtimet   stones(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyt   main>   s    c         C  s
   t  |  ƒ S(   N(   t   Proc0(   R   (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR   E   s    s    i3   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 x7 | | k  rd
 | | }	 t | | ƒ }	 | d } qÕ Wt t t | |	 ƒ t t ƒ a d }
 xJ |
 t k r}| t |
 d ƒ k rdt t ƒ } n  t t |
 ƒ d ƒ }
 q4W| | }	 |	 | } d |	 | | } t | ƒ } q– Wt  ƒ  | | } | d k rÚd } n
 |  | } | | 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   Cg        (   R   t   rangeR   t
   PtrGlbNextt   PtrGlbR   t   Ident1R   t   Ident3R   R   R   t
   Array2Globt   Proc5t   Proc4t   Ident2t   Func2t   BoolGlobt   Proc7t   Proc8t
   Array1Globt   Proc1t	   Char2Globt   Func1t   Proc6t   chrt   ordt   Proc2(   R   t	   starttimet   it   nulltimet
   String1Loct   IntLoc1t   IntLoc2t
   String2Loct   EnumLoct   IntLoc3t	   CharIndexR   t   loopsPerBenchtime(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR   Q   sT    
									

	
c         C  s­   t  j ƒ  |  _ } d |  _ |  j | _ |  j | _ t | j ƒ | _ | j t k r” d | _ t |  j ƒ | _ t  j | _ t	 | j d ƒ | _ n | j ƒ  }  d  | _ |  S(   Ni   i   i
   (   R   R
   R   R   t   Proc3R   R   R)   R   R#   R   (   t   PtrParInt
   NextRecord(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR&   ‹   s    			c         C  sN   |  d } x= t  d k r6 | d } | t }  t } n  | t k r Pq q W|  S(   Ni
   R   i   (   t	   Char1Globt   IntGlobR   (   t   IntParIOt   IntLocR4   (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR,   ›   s    


	c         C  s4   t  d  k	 r t  j }  n d a t d t ƒ t  _ |  S(   Nid   i
   (   R   R   R   R<   R#   R   (   t	   PtrParOut(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR8   ¦   s
    c          C  s"   t  d k }  |  p t }  d a d  S(   NR   t   B(   R;   R"   R'   (   t   BoolLoc(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR   °   s    c           C  s   d a  t a d  S(   NR   (   R;   t   FALSER"   (    (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR   ·   s    c         C  s—   |  } t  |  ƒ s t } n  |  t k r0 t } nc |  t k rZ t d k rQ t } q“ t } n9 |  t k ro t } n$ |  t k r~ n |  t k r“ t } n  | S(   Nid   (   t   Func3t   Ident4R   R    R<   R   t   Ident5(   t	   EnumParInt
   EnumParOut(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR)   ¾   s     						c         C  s   |  d } | | } | S(   Ni   (    (   t   IntParI1t   IntParI2R>   t	   IntParOut(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR#   Ñ   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   (   R   R<   (   t	   Array1Part	   Array2ParRH   RI   R>   t   IntIndex(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR$   Ö   s    

"c         C  s$   |  } | } | | k r t  St Sd  S(   N(   R   R    (   t   CharPar1t   CharPar2t   CharLoc1t   CharLoc2(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR(   ã   s
    c         C  s    d } xD | d k rL t  |  | | | d ƒ t k r	 d } | d } q	 q	 W| d k rn | d k rn d } n  | d k r~ t S|  | k r˜ | d } t St Sd  S(   Ni   R   t   Wt   Zi   t   X(   R(   R   t   TRUERB   (   t   StrParI1t   StrParI2R>   t   CharLoc(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyR!   ë   s    !	
c         C  s   |  } | t  k r t St S(   N(   R   RU   RB   (   RF   R4   (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyRC   ü   s     t   __main__Nc         C  sH   t  |  d d d t j ƒt  d t j d d t j ƒt j d ƒ d  S(   Nt   endt    t   files   usage: %s [number_of_loops]i    id   (   R   t   syst   stderrt   argvt   exit(   t   msg(    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyt   error  s    s   %d arguments are too many;s   Invalid argument %r;(2   t   __doc__t
   __future__R    t   timeR   t   LOOPSR   R   R   R    R   RD   RE   t   objectR   RU   RB   R   R   R<   R"   R;   R'   R%   t   xR   R   R   R   R   R&   R,   R8   R   R   R)   R#   R$   R(   R!   RC   R   R]   Rb   t   lenR_   t   nargst   intR   t
   ValueError(    (    (    s<   lib/python2.7/site-packages/future/backports/test/pystone.pyt   <module>!   sV   !:			
									 