<commit_before>#! /usr/bin/env python
import sys
from rpython.jit.codewriter.policy import JitPolicy
from spyvm import model, objspace, interpreter, squeakimage

# This loads the whole mini.image in advance.  At run-time,
# it executes the tinyBenchmark.  In this way we get an RPython
# "image" frozen into the executable, mmap'ed by the OS from
# there and loaded lazily when needed :-)

# XXX this only compiles if sys.recursionlimit is high enough!
# On non-Linux platforms I don't know if there is enough stack to
# compile...
#sys.setrecursionlimit(100000)

imagefile = ""

def setup():
    space = objspace.ObjSpace()
    stream = squeakimage.Stream(filename=imagefile)
    image = squeakimage.ImageReader(space, stream).create_image()
    interp = interpreter.Interpreter(space, image)
    w_selector = interp.perform(space.wrap_string("loopTest"), "asSymbol")
    w_object = model.W_SmallInteger(0)
    s_class = w_object.class_shadow(space)
    w_method = s_class.lookup(w_selector)
    s_frame = w_method.create_frame(space, w_object)<commit_msg>Extracted variables, improved comment.<commit_after>#! /usr/bin/env python
import sys
from rpython.jit.codewriter.policy import JitPolicy
from spyvm import model, objspace, interpreter, squeakimage

# This loads an image file in advance and includes it in the
# translation-output. At run-time, the defined selector is sent
# to the defined SmallInteger. This way we get an RPython
# "image" frozen into the executable, mmap'ed by the OS from
# there and loaded lazily when needed :-)
# Besides testing etc., this can be used to create standalone
# binaries executing a smalltalk program.

sys.setrecursionlimit(100000)

imagefile = "images/mini.image"
selector = "loopTest"
receiver = 0

def setup():
    space = objspace.ObjSpace()
    stream = squeakimage.Stream(filename=imagefile)
    image = squeakimage.ImageReader(space, stream).create_image()
    interp = interpreter.Interpreter(space, image)
    w_selector = interp.perform(space.wrap_string(selector), "asSymbol")
    w_object = model.W_SmallInteger(receiver)
    s_class = w_object.class_shadow(space)
    w_method = s_class.lookup(w_selector)
    s_frame = w_method.create_frame(space, w_object)
{'fraction_non_alphanumeric': 0.09160649819494585, 'fraction_numerical': 0.00631768953068592, 'mean_word_length': 4.728682170542636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7291643', 'n_tokens_mistral': 702, 'n_tokens_neox': 671, 'n_words': 210}