I know this sounds stupid but isn't using random and generating the
benchmark data completely against the idea of a benchmark? This
doesn't look like it takes the same time to run at each invocation so
how do you compare different runs?

On Fri, Jun 15, 2012 at 8:30 AM, Grzegorz Rudnicki
<[email protected]> wrote:
> Hi,
>
> I maked new benchmark:
>
> import random,string, time
>
> t=time.time()
>
> def random_string(dl=10):
>    d = [random.choice(string.letters) for x in xrange(dl)]
>    s = "".join(d)
>    return s
>
> basic=[]
> words=[]
> n=20000   #number of basic words
> n2=5000  #number of words in text
>
> #Create list of words variants
> for i in range(n):
>    basic_word=random_string()
>    if basic_word in basic:
>        basic_word=random_string()
>    basic.append(basic_word)
>    tmp=[]
>    tmp.append(basic_word)
>    for j in range(4):
>        tmp.append(basic_word+random_string(3))
>    words.append(tmp)
>
> #Create random text
> text=[]
> for i in range(n2):
>    r1=random.randint(0,n-1)
>    r2=random.randint(0,3)
>    text.append(words[r1][r2])
>
> #Replace non basic word to basic word
> for i in range(n2):
>    for j in range(n):
>        if text[i] in words[j]:
>            text[i]=words[j][0]
>
> ok=0
> for i in range(n2):
>    if text[i] in basic:
>        ok+=1
>
> if ok==n2:
>    print("OK")
> else:
>    print("Fail")
> print(time.time()-t)
>
> This code tranform non basic word to basic word. For simply I use random 
> strings.
>
> I tested this code on Linux and CPython use 7.8 MB RAM, but Pypy use 14.5 MB 
> RAM.
>
> Grzegorz
>
>
> _______________________________________________
> pypy-dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/pypy-dev



-- 

Leonardo Santagada
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to