Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/future/backports/test/ |
| [Home] [System Details] [Kill Me] |
�
(�*^c@sdZddlmZddlmZdZdZedd�\ZZ Z
ZZde
fd ��YZdZd
Zed�Zed�Zd
aead
ad
ad
gdagtgdD]
Ze^q�adadaed�Zd�Zd�Zd�Z
d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(e)dkr�ddl*Z*d�Z+e,e*j-�dZ.e.dkr�e+de.�nUe.dkr�ye/e*j-d�Z0Wq�e1k
r�e+de*j-d�q�XneZ0ee0�ndS( 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����(tprint_function(tclockiP�s1.1iitRecordcBs)eZdddddd�Zd�ZRS(icCs1||_||_||_||_||_dS(N(tPtrComptDiscrtEnumComptIntCompt
StringComp(tselfRRRRR((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyt__init__/s
cCs%t|j|j|j|j|j�S(N(RRRRRR(R((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pytcopy7sN(t__name__t
__module__tNoneR R
(((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR-s icCs;t|�\}}tdt||f�td|�dS(Ns#Pystone(%s)
time for %d passes = %gs-This machine benchmarks at %g
pystones/second(tpystonestprintt__version__(tloopst benchtimetstones((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pytmain>scCs
t|�S(N(tProc0(R((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyREsti3c
Cs�t�}xt|�D]}qWt�|}t�at�att_tt_tt_ dt_
dt_d}dtdd<t�}x(t|�D]}t
�t�d}d}d }t}t||�ax7||krd
||} t||�} |d}q�Wttt|| �tt�ad}
xJ|
tkr}|t|
d
�krdtt�}ntt|
�d�}
q4W||} | |}d| ||}t|�}q�Wt�||}|dkr�d}n
||}||fS(Ni(sDHRYSTONE PROGRAM, SOME STRINGsDHRYSTONE PROGRAM,
1'ST STRINGi
iiiisDHRYSTONE PROGRAM, 2'ND STRINGiitAtCg(RtrangeRt
PtrGlbNexttPtrGlbRtIdent1RtIdent3RRRt
Array2GlobtProc5tProc4tIdent2tFunc2tBoolGlobtProc7tProc8t
Array1GlobtProc1t Char2GlobtFunc1tProc6tchrtordtProc2(
Rt starttimetitnulltimet
String1LoctIntLoc1tIntLoc2t
String2LoctEnumLoctIntLoc3t CharIndexRtloopsPerBenchtime((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyRQsT
cCs�tj�|_}d|_|j|_|j|_t|j�|_|jtkr�d|_t|j�|_tj|_t |jd�|_n|j�}d|_|S(Niii
(RR
RRtProc3RRR*RR$R
(tPtrParInt
NextRecord((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR'�s cCsM|d}x<tdkr6|d}|t}t}n|tkr
Pq
q
|S(Ni
Ri(t Char1GlobtIntGlobR(tIntParIOtIntLocR5((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR-�s
cCs4tdk rtj}ndatdt�t_|S(Nidi
(RR
RR=R$R(t PtrParOut((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR9�s
cCs"tdk}|pt}dadS(NRtB(R<R#R((tBoolLoc((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR
�scCsdatadS(NR(R<tFALSER#(((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR�scCs�|}t|�st}n|tkr0t}nc|tkrZtdkrQt}q�t}n9|tkrot}n$|tkr~n|tkr�t}n|S(Nid(tFunc3tIdent4RR!R=RtIdent5(t EnumParInt
EnumParOut((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR*�s
cCs|d}||}|S(Ni((tIntParI1tIntParI2R?t IntParOut((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR$�s
cCs�|d}|||<||||d<|||d<x)t||d�D]}||||<qHW|||dd|||d<||||d|<dadS(Niiiii(RR=(t Array1Part Array2ParRIRJR?tIntIndex((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR%�s
"cCs$|}|}||krtStSdS(N(RR!(tCharPar1tCharPar2tCharLoc1tCharLoc2((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR)�s
cCs�d}xD|dkrLt||||d�tkr d}|d}q q W|dkrn|dkrnd}n|dkr~tS||kr�|d}tStSdS(NiRtWtZitX(R)RtTRUERC(tStrParI1tStrParI2R?tCharLoc((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyR"�s!
cCs|}|tkrtStS(N(RRVRC(RGR5((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyRD�st__main__NcCsHt|dddtj�tdtjddtj�tjd�dS(Ntendt
tfilesusage: %s
[number_of_loops]iid(Rtsyststderrtargvtexit(tmsg((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyterrorss%d
arguments are too many;sInvalid argument %r;(2t__doc__t
__future__RttimeRtLOOPSRRRR!RRERFtobjectRRVRCRRR=R#R<R(R&txRR
RRRR'R-R9R
RR*R$R%R)R"RDRR^RctlenR`tnargstintRt
ValueError(((sA/usr/lib/python2.7/site-packages/future/backports/test/pystone.pyt<module>!sV
!: