<commit_before>import time
import pyxb.binding.generate
import pyxb.utils.domutils

max_reps = 20

def buildTest (num_reps, constraint='minOccurs="0" maxOccurs="1"'):
    edefs = []
    cdefs = []
    duse = []
    for r in xrange(num_reps):
        edefs.append('<xs:element name="rep%d" type="xs:string"/>' % (r,))
        cdefs.append('<xs:element ref="rep%d" %s/>' % (r, constraint))
        duse.append('<rep%d>text</rep%d>' % (r, r))

    schema = ''.join([ '''<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">''',
                   "\n".join(edefs),
                   '''<xs:element name="collection">
<xs:complexType><xs:sequence>''',
                   "\n".join(cdefs),
                   '''</xs:sequence></xs:complexType>
</xs:element>
</xs:schema>''' ])

    xmls = '<collection>' + ''.join(duse) + '</collection>'
    
    return (schema, xmls)

for size in xrange(1, max_reps):
    (schema, xmls) = buildTest(size)

    t0 = time.time()
    code = pyxb.binding.generate.GeneratePython(schema_text=schema)
    t1 = time.time()
    rv = compile(code, 'test', 'exec')
    t2 = time.time()
    eval(rv)
    t3 = time.time()
    ct0 = time.time()
    doc = CreateFromDocument(xmls)
    ct1 = time.time()

    print "%d gen=%g cpl=%g ld=%g prs=%g" % (size, t1 - t0, t2 - t1, t3 - t2, ct1 - ct0)
    #file('code.py', 'w').write(code)

<commit_msg>Denote element number in content<commit_after>import time
import pyxb.binding.generate
import pyxb.utils.domutils

max_reps = 20

def buildTest (num_reps, constraint='minOccurs="0" maxOccurs="1"'):
    edefs = []
    cdefs = []
    duse = []
    for r in xrange(num_reps):
        edefs.append('<xs:element name="rep%d" type="xs:string"/>' % (r,))
        cdefs.append('<xs:element ref="rep%d" %s/>' % (r, constraint))
        duse.append('<rep%d>text_%d</rep%d>' % (r, r, r))

    schema = ''.join([ '''<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">''',
                   "\n".join(edefs),
                   '''<xs:element name="collection">
<xs:complexType><xs:sequence>''',
                   "\n".join(cdefs),
                   '''</xs:sequence></xs:complexType>
</xs:element>
</xs:schema>''' ])

    xmls = '<collection>' + ''.join(duse) + '</collection>'
    
    return (schema, xmls)

for size in xrange(1, max_reps):
    (schema, xmls) = buildTest(size)

    t0 = time.time()
    code = pyxb.binding.generate.GeneratePython(schema_text=schema)
    t1 = time.time()
    rv = compile(code, 'test', 'exec')
    t2 = time.time()
    eval(rv)
    t3 = time.time()
    #file('code.py', 'w').write(code)
    #print xmls
    ct0 = time.time()
    doc = CreateFromDocument(xmls)
    ct1 = time.time()

    print "%d gen=%g cpl=%g ld=%g prs=%g" % (size, t1 - t0, t2 - t1, t3 - t2, ct1 - ct0)
    #file('code.py', 'w').write(code)


{'fraction_non_alphanumeric': 0.20846340617412418, 'fraction_numerical': 0.018730489073881373, 'mean_word_length': 2.8249336870026527, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 2, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 13}, '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': '490176', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1077, 'n_words': 209}