GProf a.k.a. Groovy gprof was just born Yesterday [https://code.google.com/p/gprof/]. GProf is a profiler for Groovy [http://groovy.codehaus.org/]. It allows you to determine which parts of a program are taking most of the execution time like GNU gprof does for C, C++.
For example, in the following code, GProf shows you that YourApp has two slow operation; one is a task that is short but repeated many times and another is a long task.
class YourApp { void start() { def foo = new Foo() for (int i = 0; i < 100; i++) { foo.doShortTask() } def bar = new Bar() bar.doLongTask() } } class Bar { void doLongTask() { for (int i = 0; i < 1000000; i++); } } class Foo { void doShortTask() { for (int i = 0; i < 10000; i++); } } profile { // or new gprof.Profiler().run { new YourApp().start() }.prettyPrint() /* stdout % calls total ms ms/call min ms max ms method class 47.59 1 54.33 54.33 54.33 54.33 doLongTask Bar 40.05 100 45.72 0.46 0.29 2.09 doShortTask Foo 11.92 1 13.61 13.61 13.61 13.61 start YourApp 0.18 1 0.21 0.21 0.21 0.21 ctor YourApp 0.13 1 0.14 0.14 0.14 0.14 ctor Bar 0.13 1 0.14 0.14 0.14 0.14 ctor Foo */Please try GProf and send me your feecback. Enjoy!
No comments:
Post a Comment