From: D-Man <ds...@ri...> - 2001-04-05 15:30:36
|
On Thu, Apr 05, 2001 at 10:57:40AM -0300, German Morales wrote: | Hi everybody, ... | I'm looking for a tool that show me the time elapsed in | each Jython function or method. | | Having found nothing in a quick search on Google and with | the same result in this lists, I've made some changes to | PyTableCode.java, so when I execute 'jython Test.py', | where Test.py is: ... | | I get this result: | | ## ---------------------------------------- | begin - time:986420318682 - code:? | begin - time:986420318685 - code:TestClass | end - time:986420318686 | begin - time:986420318686 - code:createFunction | begin - time:986420318687 - code:__main__.TestClass.__init__ | end - time:986420318687 | end - time:986420318687 | begin - time:986420318688 - code:__main__.TestClass.printFunction | begin - time:986420318691 - code:__main__.TestClass.__str__ | end - time:986420318697 | end - time:986420318701 | end - time:986420318701 | ## ---------------------------------------- | | The numbers are java.lang.System.currentTimeMillis() calls. | | The next step is to write a program to analize this output. | | But, before going on with my efforts, I wish to ask you some | questions. | | | 0. There is some tool already done to do this job? I don't know of any. | 1. If not... What do you think of my aproach? It is good, but perhaps you could make it easier on yourself. If it isn't too difficult with your framework, I would recommend trying something like the following : begin = java.lang.System.currentTimeMillis() some_func_that_may_take_some_time() end = java.lang.System.currentTimeMillis() print "some_func took %d ms" % ( end - begin ) Seeing the difference in time is more interesting (useful) than the actual start/end times. I expect you were planning on writing a tool to parse your existing output and do the subtraction there. It may be easier to do that right in the test framework. | 2. Is someone else interested in profiling jython code? Sure. It would be nice to see just how slow (or fast ;-)) it really is. It is also very useful when needing to present data to superiors. A little while back I used Jython to run some performance tests on a method in our Java runtime that was known to be slow. I made some modifications and ran the profiling again. It was a custom profiling very similar to the above snippet. While the numbers weren't exact (they never are anyways) it gave a good approximation. Jython also made checking the accuracy of the modifications easier. For my final report I used the same (custom) benchmark application written in Java that was used for the initial report. -D |