Administrator
|
Stephen and I and others have been looking into java based scripting
languages lately. BeanShell and Jython certainly looked interesting. Here's a few articles: http://www.javaworld.com/javaworld/jw-04-2002/jw-0405-scripts_p.html http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-beanshell_p.html Netlogo also could be considered, if the logo language could be separated from the simulation environment. In the first article, a million times loop was tried. Beanshell did poorly, around 20 seconds on my system. NetLogo did 2 seconds, not bad! Jython (and Python itself) did 1.1 seconds, and Stephen found that Lingo, the Macromedia Director language (not Java based) did really well at 170 ms. Java comes in at 8ms .. quite fast. (I tried to get Jython to byte conpile, and to compile to Java, but I got results similar to the vanilla trial, leading me to think that I did it wrong.) But just recently, Pnuts, an older java scripting language, got new life and is being supported by Sun. Its very light weight and has good automatic incremental compiling. It seems very well designed and easy to use as well. Trying it on the million loop test proved to be very interesting! First, it seemed pretty snappy, doing while and for loops at around .8 seconds. But really interesting was a performance section in the documentation that mentioned that really long loops might incur a performance penalty due to the way numerics work (for Java folks: they use classes for all numbers .. so Interger etc) and that a more efficient method is to use the "foreach" built-in. When I did that, the time tests went to .3 seconds using one form, and a quick .09 secs for a second form! I'm really encouraged by this and hope to pursue it further. BTW: One reason we're interested in Java is the rich suite of libraries. Python/Jython also are good from that perspective but their libraries tend to have multiple conflicting implementations, at least in the 3D space. And with Java becoming widely distributed, a java based approach seems reasonable. Attached is the pnuts test for your perusal. Owen Densmore 908 Camino Santander Santa Fe, NM 87505 [hidden email] Cell: 505-570-0168 Home: 505-988-3787 AIM:owendensmore http://complexityworkshop.com http://backspaces.net pnuts ~/src/pnuts/test.pnut for loop: 834 ms for loop: 786 ms while loop: 782 ms while loop: 838 ms foreach loopEnum loop: 92 ms foreach loopEnum loop: 89 ms foreach rangeEnum loop: 303 ms foreach rangeEnum loop: 280 ms ~/src/pnuts/test.pnut: (note use of function variables!) loops=1000000; function timetest(s, fn) { fn(1) // get it compiled t0 = System::currentTimeMillis(); fn(loops) println (s + (System::currentTimeMillis() - t0) + " ms"); } function fortest(n) {for (i=0;i<loops;i++) {}} timetest("for loop: ", fortest) timetest("for loop: ", fortest) function whiletest(n) {i=0; while (i<loops) {i++}} timetest ("while loop: ", whiletest); timetest ("while loop: ", whiletest); function foreachtest1(n) {foreach i (loopEnum(loops)){}} timetest ("foreach loopEnum loop: ", foreachtest1); timetest ("foreach loopEnum loop: ", foreachtest1); function foreachtest2(n) {foreach i (rangeEnum(0, loops-1)){}} timetest ("foreach rangeEnum loop: ", foreachtest2); timetest ("foreach rangeEnum loop: ", foreachtest2); |
Of course, tight repeat loop tests only give a small sense of
performance...we're also doing some comparisons on tasks that are more representative of general ABM and visualization tasks. Rich Harris has been back messing with C++ lately for possible binding to Python. As a test he implemented a standard Fire cellular automata and rendered it in OpenGL. As the model uses periodic boundary conditions, he rendered the CA on the surface of a torus. You can download his test app at http://www.redfish.com/rharris/FireModel3D.exe (windows only for now). It pretty good performance for a 512x256 CA. Here's a quick test of the same model in Director's Lingo. www.redfish.com/projects/SwarmEffects/ringOfFire.htm. It's not a true comparison as this only uses a 128x64 CA. Though one positive point is that total development time was 1 hour. We're not being very scientific on our results gathering, just looking around and getting an overall feeling of the different potential paths. We're now screwing around with Python/OpenGL to get a feel for performance and how easy the deployment can be... -S ____________________________________________________ http://www.redfish.com [hidden email] 624 Agua Fria Street office: (505)995-0206 Santa Fe, NM 87501 mobile: (505)577-5828 > -----Original Message----- > From: Owen Densmore [mailto:[hidden email]] > Sent: Wednesday, December 17, 2003 9:26 AM > To: The Friday Morning Complexity Coffee Group > Subject: [FRIAM] Pnut: Java Scripting Language > > > Stephen and I and others have been looking into java based scripting > languages lately. BeanShell and Jython certainly looked interesting. > Here's a few articles: > http://www.javaworld.com/javaworld/jw-04-2002/jw-0405-scripts_p.html > http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-beanshell_p.html > Netlogo also could be considered, if the logo language could be > separated from the simulation environment. > > In the first article, a million times loop was tried. Beanshell did > poorly, around 20 seconds on my system. NetLogo did 2 seconds, not > bad! Jython (and Python itself) did 1.1 seconds, and Stephen found > that Lingo, the Macromedia Director language (not Java based) did > really well at 170 ms. Java comes in at 8ms .. quite fast. (I tried > to get Jython to byte conpile, and to compile to Java, but I got > results similar to the vanilla trial, leading me to think that I did it > wrong.) > > But just recently, Pnuts, an older java scripting language, got new > life and is being supported by Sun. Its very light weight and has good > automatic incremental compiling. It seems very well designed and easy > to use as well. Trying it on the million loop test proved to be very > interesting! > > First, it seemed pretty snappy, doing while and for loops at around .8 > seconds. But really interesting was a performance section in the > documentation that mentioned that really long loops might incur a > performance penalty due to the way numerics work (for Java folks: they > use classes for all numbers .. so Interger etc) and that a more > efficient method is to use the "foreach" built-in. When I did that, > the time tests went to .3 seconds using one form, and a quick .09 secs > for a second form! > > I'm really encouraged by this and hope to pursue it further. BTW: One > reason we're interested in Java is the rich suite of libraries. > Python/Jython also are good from that perspective but their libraries > tend to have multiple conflicting implementations, at least in the 3D > space. And with Java becoming widely distributed, a java based > approach seems reasonable. > > Attached is the pnuts test for your perusal. > > Owen Densmore 908 Camino Santander Santa Fe, NM 87505 > [hidden email] Cell: 505-570-0168 Home: 505-988-3787 > AIM:owendensmore http://complexityworkshop.com http://backspaces.net > > pnuts ~/src/pnuts/test.pnut > for loop: 834 ms > for loop: 786 ms > while loop: 782 ms > while loop: 838 ms > foreach loopEnum loop: 92 ms > foreach loopEnum loop: 89 ms > foreach rangeEnum loop: 303 ms > foreach rangeEnum loop: 280 ms > > ~/src/pnuts/test.pnut: (note use of function variables!) > > loops=1000000; > function timetest(s, fn) { > fn(1) // get it compiled > t0 = System::currentTimeMillis(); > fn(loops) > println (s + (System::currentTimeMillis() - t0) + " ms"); > } > > function fortest(n) {for (i=0;i<loops;i++) {}} > timetest("for loop: ", fortest) > timetest("for loop: ", fortest) > > function whiletest(n) {i=0; while (i<loops) {i++}} > timetest ("while loop: ", whiletest); > timetest ("while loop: ", whiletest); > > function foreachtest1(n) {foreach i (loopEnum(loops)){}} > timetest ("foreach loopEnum loop: ", foreachtest1); > timetest ("foreach loopEnum loop: ", foreachtest1); > > function foreachtest2(n) {foreach i (rangeEnum(0, loops-1)){}} > timetest ("foreach rangeEnum loop: ", foreachtest2); > timetest ("foreach rangeEnum loop: ", foreachtest2); > > > ============================================================ > FRIAM Applied Complexity Group listserv > Meets Fridays 9AM @ Jane's Cafe > Lecture schedule, archives, unsubscribe, etc.: > http://www.friam.org > > |
Stephen Guerin wrote:
... > We're now screwing around with Python/OpenGL to get a feel for performance > and how easy the deployment can be... My developer associates, previously Perl and Python devotees, have all switched to Ruby. I don't think there is direct binding to Java (like Jython), but the back end data collection for one of the applications which uses JGraph is all written in Ruby. I have to say, I was impressed with development speed when one of them scripted up a web proxy that translated from http to https in a day using Ruby. Owen Densmore wrote: >>But just recently, Pnuts, Any relation to acorn? >>Python/Jython My only experience with Jython has been trying to use Jython to create an unauthorized, privileged class in a Java program. Apparently, if one allows Jython to interact directly with one's Java program, an adversary can bypass the security manager through the "back-door" thus created. That's probably not a problem for you, but it does show the complexity of managing security. -- Ray Parks [hidden email] IDART Project Lead Voice:505-844-4024 IORTA Department Fax:505-844-9641 http://www.sandia.gov/idart Pager:800-690-5288 |
Free forum by Nabble | Edit this page |