You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Ralph Johnson <jo...@cs.uiuc.edu> on 2015/07/02 17:51:22 UTC

question about Groovy syntax

I'm using a package called gprof that profiles Groovy code, and it has been
very useful.

You are supposed to be able to write

profile {your code goes here}.prettyPrint()

and it will print out a profile of your code on the console.   But that
doesn't work for me.  I read the code and found what I thought was the
definition of "profile" in ProfileStaticExtension

Its definition is

public class ProfileStaticExtension {

    static Report profile(Object selfType, Callable profiled) {

        return new Profiler().run(profiled);

    }

    static Report profile(Object selfType, Map options, Callable profiled) {

        return new Profiler().run(options, profiled);

    }

}

So, I tried writing

ProfileStaticExtension.profile(null, {your code goes here}).prettyPrint()

and that worked!   Do you have any idea why the syntax that they advertised
doesn't work?  It certainly is a nicer syntax than what I am using.  I'm
using it in Eclipse and I thought maybe I had the class path set up
incorrectly, but it looks good to me.

new Profiler.profile({your code here}).prettyPrint() works, too.

Re: question about Groovy syntax

Posted by Ralph Johnson <jo...@cs.uiuc.edu>.
Thanks for your answer.   I had never heard of "extension descriptors" and
would not have known where to look for them.  But Google showed me some
blogs on it, and I was able to figure it out.

-Ralph Johnson

On Thu, Jul 2, 2015 at 11:04 AM, Cédric Champeau <ce...@gmail.com>
wrote:

> This suggests that the extension descriptor is not on classpath. Usually
> an extension is bundled as a jar, which contains the descriptor. So if you
> are using this jar, it should work. If you are using an exploded form, then
> make sure the descriptor is on classpath.
>
> 2015-07-02 17:51 GMT+02:00 Ralph Johnson <jo...@cs.uiuc.edu>:
>
>> I'm using a package called gprof that profiles Groovy code, and it has
>> been very useful.
>>
>> You are supposed to be able to write
>>
>> profile {your code goes here}.prettyPrint()
>>
>> and it will print out a profile of your code on the console.   But that
>> doesn't work for me.  I read the code and found what I thought was the
>> definition of "profile" in ProfileStaticExtension
>>
>> Its definition is
>>
>> public class ProfileStaticExtension {
>>
>>     static Report profile(Object selfType, Callable profiled) {
>>
>>         return new Profiler().run(profiled);
>>
>>     }
>>
>>     static Report profile(Object selfType, Map options, Callable
>> profiled) {
>>
>>         return new Profiler().run(options, profiled);
>>
>>     }
>>
>> }
>>
>> So, I tried writing
>>
>> ProfileStaticExtension.profile(null, {your code goes here}).prettyPrint()
>>
>> and that worked!   Do you have any idea why the syntax that they
>> advertised doesn't work?  It certainly is a nicer syntax than what I am
>> using.  I'm using it in Eclipse and I thought maybe I had the class path
>> set up incorrectly, but it looks good to me.
>>
>> new Profiler.profile({your code here}).prettyPrint() works, too.
>>
>
>

Re: question about Groovy syntax

Posted by Cédric Champeau <ce...@gmail.com>.
This suggests that the extension descriptor is not on classpath. Usually an
extension is bundled as a jar, which contains the descriptor. So if you are
using this jar, it should work. If you are using an exploded form, then
make sure the descriptor is on classpath.

2015-07-02 17:51 GMT+02:00 Ralph Johnson <jo...@cs.uiuc.edu>:

> I'm using a package called gprof that profiles Groovy code, and it has
> been very useful.
>
> You are supposed to be able to write
>
> profile {your code goes here}.prettyPrint()
>
> and it will print out a profile of your code on the console.   But that
> doesn't work for me.  I read the code and found what I thought was the
> definition of "profile" in ProfileStaticExtension
>
> Its definition is
>
> public class ProfileStaticExtension {
>
>     static Report profile(Object selfType, Callable profiled) {
>
>         return new Profiler().run(profiled);
>
>     }
>
>     static Report profile(Object selfType, Map options, Callable
> profiled) {
>
>         return new Profiler().run(options, profiled);
>
>     }
>
> }
>
> So, I tried writing
>
> ProfileStaticExtension.profile(null, {your code goes here}).prettyPrint()
>
> and that worked!   Do you have any idea why the syntax that they
> advertised doesn't work?  It certainly is a nicer syntax than what I am
> using.  I'm using it in Eclipse and I thought maybe I had the class path
> set up incorrectly, but it looks good to me.
>
> new Profiler.profile({your code here}).prettyPrint() works, too.
>