31 messages in org.codehaus.groovy.devRe: [groovy-dev] as usual on performa...
FromSent OnAttachments
Alex Tkachman27 Feb 2008 05:38 
Guillaume Laforge27 Feb 2008 05:47 
Alex Tkachman27 Feb 2008 06:01 
Chanwit Kaewkasi27 Feb 2008 06:21 
Martin C. Martin27 Feb 2008 06:27 
Jochen Theodorou27 Feb 2008 06:32 
Jochen Theodorou27 Feb 2008 06:33 
tugwilson27 Feb 2008 06:55 
Chanwit Kaewkasi27 Feb 2008 07:15 
Chanwit Kaewkasi27 Feb 2008 08:01 
Jochen Theodorou27 Feb 2008 08:28 
tugwilson27 Feb 2008 09:00 
tugwilson27 Feb 2008 09:55 
Chanwit Kaewkasi27 Feb 2008 11:27 
Chanwit Kaewkasi27 Feb 2008 11:31 
Jochen Theodorou27 Feb 2008 11:36 
Alex Tkachman27 Feb 2008 11:58 
Martin C. Martin27 Feb 2008 12:18 
Jochen Theodorou27 Feb 2008 12:37 
Jochen Theodorou27 Feb 2008 12:45 
tugwilson27 Feb 2008 12:48 
tugwilson27 Feb 2008 12:51 
Martin C. Martin27 Feb 2008 13:27 
Alex Tkachman27 Feb 2008 13:48 
tugwilson27 Feb 2008 14:14 
Jochen Theodorou27 Feb 2008 17:09 
Alexandru Popescu ☀27 Feb 2008 17:38 
Charles Oliver Nutter28 Feb 2008 00:20 
Jochen Theodorou28 Feb 2008 01:33 
Alexandru Popescu ☀28 Feb 2008 02:56 
tugwilson28 Feb 2008 03:29 
Subject:Re: [groovy-dev] as usual on performance - operations on primitives
From:Alex Tkachman (alex@gmail.com)
Date:02/27/2008 01:48:56 PM
List:org.codehaus.groovy.dev

ASs long as you sure that 'plus' doesn't change meta class

On Thu, Feb 28, 2008 at 12:27 AM, Martin C. Martin <mar@martincmartin.com> wrote:

tugwilson wrote:

Jochen Theodorou wrote:

tugwilson schrieb: [...]

The main execution cost is fetching the MetaClass for b (Ng wraps ints in NgInt which has a getMetaClass method rather than Integer which requires a registry lookup), a check to see if a Category has changed the plus operation on int and a check that the plus operation on int has not been monkey patched. These costs are exactly equivalent to your "Integer#plus(Integer) is default" check, except the cost of getting the MetaClass for Integer is higher in Groovy.

well... theoretically it is enough to reuse that check for a certain amount of actions... for example:

int j=0; for (int i=0; i<n i++) { j+=i }

In this case we could check the MetaClass for Integer and if it is not modified, we could execute the code in its static form. This means for all n nest() calls and all n plus class we have only a single MetaClass check.

Checking outside the loop?

If so you're just deliberately breaking the semantics of the language.

I think Jochen's intention is to move a loop invariant outside the loop. The example is so simple and self contained that metaclasses can't change within the loop.

Moving a constant calculation outside a loop is a standard optimization which doesn't change the semantics; I don't think Jochen meant that all loops (or even most loops) could be handled that way.

Best, Martin

--------------------------------------------------------------------- To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

--------------------------------------------------------------------- To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email