From: Patrick C. <pat...@ya...> - 2005-03-24 22:28:48
|
http://sourceforge.net/tracker/?group_id=12867&atid=112867&func=detail&aid=674932 --- Todd Moyer <tm...@in...> wrote: > > I spent a bit of time digging into the Jython source > to see if there was > an obvious explanation. It seems about 75% of the > time with "print > >>output" is related to the FixedFileWrapper that > the output file is > wrapped in for every print call. Just as an > experiment, I tried > allowing the file to default to stdout, as in "print > 'test'", > significantly reducing the time. It is still a lot > slower than > "output.write ('test')" though. Interesting find, > Kent. > > As far as writing critical code in Java, it's a nice > option to have. > However, I rarely find I need to resort to it. > Because I can write > Jython much faster than Java, I find spending some > of that saved time > tuning the algoriths nearly always yields acceptable > performance. > Careless algoritms can sink code written in any > language, and often does. > > Cheers, > Todd Moyer > > > Alex Greif wrote: > > > As I understand the Jython philosophy, performance > critical parts > > should be better implemented in java. > > > > Alex. > > > > > > On Wed, 23 Mar 2005 13:43:07 -0800 (PST), Patrick > Chamberlain > > <pat...@ya...> wrote: > > > >>I've seen that before. I think it's a known bug. > >> > >>The workaround I use is to use a Java way to print > >>instead such as a FileOutputStream. > >> > >>Patrick > >>--- Kent Johnson <ke...@td...> wrote: > >> > >>>I just tracked down a huge performance problem in > my > >>>app to use of print >> output. My program was > >>>taking five seconds to output a 200 line, 5Kb > file > >>>(ouch!) > >>> > >>>Here is a program that shows the problem: > >>> > >>># FileWriteTest.py > >>>from java.lang.System import currentTimeMillis > >>> > >>>start = currentTimeMillis() > >>> > >>>output = open('junk1', 'w') > >>>for i in range(100): > >>> print >>output, 'test' > >>>output.close() > >>> > >>>elapsed = currentTimeMillis() - start > >>>print 'Using print >>', elapsed > >>> > >>>start = currentTimeMillis() > >>> > >>>output = open('junk2', 'w') > >>>for i in range(100): > >>> output.write('test') > >>> output.write('\n') > >>>output.close() > >>> > >>>elapsed = currentTimeMillis() - start > >>>print 'Using write ', elapsed > >>> > >>>### > >>> > >>>On my computer the output is > >>>Using print >> 1382 > >>>Using write 30 > >>> > >>>so output using print >> takes about 40 times as > >>>long as the same thing with write()! > >>> > >>>I'm not going to take this any further, I'm > >>>reporting it to help others avoid the same hole, > and > >>>in > >>>hopes that someone might fix this going forward > :-) > >>> > >>>Kent > >>> > >>> > >>> > >>> > >> > >>------------------------------------------------------- > >> > >>>This SF.net email is sponsored by Microsoft > Mobile & > >>>Embedded DevCon 2005 > >>>Attend MEDC 2005 May 9-12 in Vegas. Learn more > about > >>>the latest Windows > >>>Embedded(r) & Windows Mobile(tm) platforms, > >>>applications & content. Register > >>>by 3/29 & save $300 > >>> > >> > >>http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click > >> > >>>_______________________________________________ > >>>Jython-users mailing list > >>>Jyt...@li... > >>> > >> > >>https://lists.sourceforge.net/lists/listinfo/jython-users > >> > >>------------------------------------------------------- > >>This SF.net email is sponsored by Microsoft Mobile > & Embedded DevCon 2005 > >>Attend MEDC 2005 May 9-12 in Vegas. Learn more > about the latest Windows > >>Embedded(r) & Windows Mobile(tm) platforms, > applications & content. Register > >>by 3/29 & save $300 > http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click > >>_______________________________________________ > >>Jython-users mailing list > >>Jyt...@li... > >>https://lists.sourceforge.net/lists/listinfo/jython-users > >> > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by Microsoft Mobile > & Embedded DevCon 2005 > > Attend MEDC 2005 May 9-12 in Vegas. Learn more > about the latest Windows > > Embedded(r) & Windows Mobile(tm) platforms, > applications & content. Register > > by 3/29 & save $300 > http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT > Products from real users. > Discover which products truly live up to the hype. > Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > > |