File: targetrpystonex.py

package info (click to toggle)
pypy 5.6.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 97,040 kB
  • ctags: 185,069
  • sloc: python: 1,147,862; ansic: 49,642; cpp: 5,245; asm: 5,169; makefile: 529; sh: 481; xml: 232; lisp: 45
file content (39 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from rpython.translator.test import rpystone
from rpython.rlib.objectmodel import current_object_addr_as_int


def make_target_definition(LOOPS):
    def entry_point(loops):
        g = rpystone.g
        g.IntGlob = 0
        g.BoolGlob = 0
        g.Char1Glob = '\0'
        g.Char2Glob = '\0'
        for i in range(51):
            g.Array1Glob[i] = 0
        for i in range(51):
            for j in range(51):
                g.Array2Glob[i][j] = 0
        g.PtrGlb = None
        g.PtrGlbNext = None
        return rpystone.pystones(loops), current_object_addr_as_int(g)

    def target(*args):
        return entry_point, [int]
    
    def run(c_entry_point):
        res = c_entry_point(LOOPS)
        (benchtime, stones), _ = res
        print "translated rpystone.pystones time for %d passes = %g" % \
              (LOOPS, benchtime)
        print "This machine benchmarks at %g translated rpystone pystones/second" % (stones,)
        res = c_entry_point(50000)
        _, g_addr = res
        print "CPython:"
        benchtime, stones = rpystone.pystones(50000)
        print "rpystone.pystones time for %d passes = %g" % \
              (50000, benchtime)
        print "This machine benchmarks at %g rpystone pystones/second" % (stones,)

    return entry_point, target, run