From: German M. <ger...@de...> - 2001-04-05 14:00:24
|
Hi everybody, Before anything else, sorry for my English. I don't know if this is message should go in jython-users list or in the jython-dev list, so I apologize in advance if it is in the wrong place. I'm new in the list, but I used JPython (now Jython) on and off for about 2 years. I have an application written in Java that uses Jython for the annoying business details, as a way for my customers to customize the application for their needs. Anything goes OK, but I'm concerned about the performance. In a standard Java application, you can use a Java Profiler (there are a lot) to see where the performance bottleneck is. In the case of a Jython code, those profilers come up with a useless conclusion: the time is consumed in PythonInterpreter.exec(PyCode compiledPyCode). 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: ## ---------------------------------------- class TestClass: def __init__(self): self.a = 1 def __str__(self): return str(self.a) def printFunction(_testClass): print str(_testClass) def createFunction(): return TestClass() _testClass = createFunction() printFunction(_testClass) ## ---------------------------------------- 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? 1. If not... What do you think of my aproach? 2. Is someone else interested in profiling jython code? Thanks in advance for your time. German Morales |
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 |