31 messages in org.codehaus.groovy.devRe: [groovy-dev] as usual on performa...
FromSent OnAttachments
Alex TkachmanFeb 27, 2008 5:38 am 
Guillaume LaforgeFeb 27, 2008 5:47 am 
Alex TkachmanFeb 27, 2008 6:01 am 
Chanwit KaewkasiFeb 27, 2008 6:21 am 
Martin C. MartinFeb 27, 2008 6:27 am 
Jochen TheodorouFeb 27, 2008 6:32 am 
Jochen TheodorouFeb 27, 2008 6:33 am 
tugwilsonFeb 27, 2008 6:55 am 
Chanwit KaewkasiFeb 27, 2008 7:15 am 
Chanwit KaewkasiFeb 27, 2008 8:01 am 
Jochen TheodorouFeb 27, 2008 8:28 am 
tugwilsonFeb 27, 2008 9:00 am 
tugwilsonFeb 27, 2008 9:55 am 
Chanwit KaewkasiFeb 27, 2008 11:27 am 
Chanwit KaewkasiFeb 27, 2008 11:31 am 
Jochen TheodorouFeb 27, 2008 11:36 am 
Alex TkachmanFeb 27, 2008 11:58 am 
Martin C. MartinFeb 27, 2008 12:18 pm 
Jochen TheodorouFeb 27, 2008 12:37 pm 
Jochen TheodorouFeb 27, 2008 12:45 pm 
tugwilsonFeb 27, 2008 12:48 pm 
tugwilsonFeb 27, 2008 12:51 pm 
Martin C. MartinFeb 27, 2008 1:27 pm 
Alex TkachmanFeb 27, 2008 1:48 pm 
tugwilsonFeb 27, 2008 2:14 pm 
Jochen TheodorouFeb 27, 2008 5:09 pm 
Alexandru Popescu ☀Feb 27, 2008 5:38 pm 
Charles Oliver NutterFeb 28, 2008 12:20 am 
Jochen TheodorouFeb 28, 2008 1:33 am 
Alexandru Popescu ☀Feb 28, 2008 2:56 am 
tugwilsonFeb 28, 2008 3:29 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [groovy-dev] as usual on performance - operations on primitivesActions...
From:Alex Tkachman (alex@gmail.com)
Date:Feb 27, 2008 1: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