[ZPT] Poor Jython ZPT performance: Regular Expressions.

Alan Kennedy zpt@xhaus.com
Wed, 6 Mar 2002 05:38:47 EST5EDT


Greetings,

I posted some jython ZPT performance figures the other day. 
After doing a simple bit of profiling, I think the culprit 
for slowing them down so much (a factor of 10 to 20) was 
the poor performance of regular expressions in jython. I 
ran the following simple regex performance test on Cpython 
(2.1.1), Jython(Jview) and Jython (jdk1.3.1), on a 1.2Ghz 
Athlon.

#---------------------------------------------------
# simple RE vs. PRE benchmark

import re, pre
import time

# 1/3 first-choice hits, 1/3 second-choice hits, 1/3 misses
text = (["pmos95"] * 333 + ["lmos95"] * 333 + ["xmos95"] * 
334) * 10

pattern = "(p|l)mos95"

def bench(p):
    t0 = time.clock()
    for line in text:
        pass
    t1 = time.clock() - t0
    for line in text:
        p.match(line)
    return time.clock() - t0 - 2*t1

print "SRE", bench(re.compile(pattern))
print "PRE", bench(pre.compile(pattern))
#---------------------------------------------------

The CPython 2.1.1 output was 

SRE 0.0170848529632
PRE 0.117309881563

The Jython (Jview) output was

SRE 0.10100007057189941
PRE 0.09000003337860107

And the Jython (jdk1.3.1) output was

SRE 0.1499999761581421
PRE 0.13999998569488525

So, it appears that regular expressions are not that fast 
in Jython.

Alan.


---------------------------------------------
This message was sent using WebMail by CyberGate.
http://www.gate.net/webmail