From: Bill K. <bi...@ct...> - 2001-10-04 08:39:06
|
From: "Carlos Quiroz" <car...@we...> > > On Thursday 04 October 2001 00:23, Mat...@i2... wrote: > > > Heh, yeah, I wrote a GUI jython script launcher initially in jython, it > > was about 1000 lines, had to rewrite it in Java (for speed) and it was > > > 2300 lines, so I feel your pain =) > > Hi. > Do you have any estimation how much slower is using jython than java? I'm > very interested to know that kind of figure I have extensive timing and profiling numbers for our jython html parser and layout engine, and a rewrite of the layout engine in java. Well, 'extensive' in the sense that I accumulated a lot of them in trying to tweak the jython code in the hopes of not having to rewrite it. :) The parser, interestingly perhaps, hasn't needed to be rewritten in Java. The parser, however, is very simple, relying on the lexer to do most of the work - and the lexer is just a big regexp - and so in that sense we can say the lexer is 'written in java' (in terms of the performance of the regexp engine, I mean. Certainly no-one in their right mind would write a lexer >in java< when they could do it in a couple lines of regexp. ;-) Okay. So there's a point I'm trying to get to about the ratio of jython-to-java, or rather, the percentage or degree to which a bunch of jython code relies heavily on calls to Java classes to do much of its work - sort of a 'glue' or scripting for the Java components, to put them together and get them to do things; vs. jython code implementing an algorithm strictly in pure jython. I think our layout engine falls squarely in the latter category, while our parser falls to a degree toward the former; . . . well anyway, here are some numbers :) The test data for these was a simple html document of 1364 words (9893 characters) with a couple dozen tags strewn throughout, and an inline image contained in a simple table. The jython implementation: parse x 100: 3.5049999952316284 secs (0.03504999995231629/per) layout x 10: 3.8459999561309814 secs (0.38459999561309816/per) So layout was accomplished in about 2/5ths of a second. But, this is timed on a 1.3GHz athlon system, and our product's minimum requirements specify a Pentium 166Mhz (or similar speed Macintosh.) And unfortunately, the _three seconds_ the layout might be expected to take on such a machine (and indeed did) were a bit more that it seemed reasonable to ask users to tolerate. =) Anyway here's the java reimplementation (port really) of the layout engine (again on the GHz athlon) layout x 1000: 8.332000017166138 secs (0.008332000017166137/per) Zoom! Not quite two orders of magnitude but, just about one-and-a-half . . . But, again, what we're doing in the layout engine - 'pure' jython, no Java methods called at all, really, 'cept, well okay stringWidth() from FontMetrics, not much else - is about as biased an example toward the poor-performance end of the spectrum as one can get. We're quite happy with the performance of the rest of our jython modules, including the parser - and the ones that do things like glue swing components together - I mean, speed just hasn't been a problem for those kinds of modules. So I didn't want to sound in any of this like I'm down on jython or anything. I love it actually, it's the best alternative to Java going right now ! O:-) That runs on the JVM I mean. <g> Okay. Hope this helps, Regards, Bill |