bobobear / lambdaj

Automatically exported from code.google.com/p/lambdaj
Apache License 2.0
0 stars 0 forks source link

sumFrom Enhancement #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

this is not really an Issue. It's  maybe an suggestion for the sumFrom
function. I am not really sure that is yet already possible.

For example i have the following person class:

class Person{
   int age;
   int iq;
   int count1;
   int count2;
}

So now i want to sum all of the variables from a list of persons.

Person personSum = sumFrom(persons);
personSum.getAge();
personSum.getIq();
personSum.getCount1();
personSum.getCount2();

The problem is that for each variables i whant to sum, the hole list is
iterated. Or did i get it wrong?

Wouldn't it be better so sum all variables with the sumFrom(persons); call,
and then cache it in the proxy object?

PS: I did'nt find a better place to post this...sorry
Excelent library! Keep it up!

Original issue reported on code.google.com by meleagro...@googlemail.com on 30 Aug 2009 at 6:08

GoogleCodeExporter commented 9 years ago
About the 95% of time is spent by lambdaj introspecting the beans in order to 
gather
the values from their properties. That means that in your example the
personSum.getAge() invocation will be almost 4 times slower, making 
instantaneous the
following 3 invocations. 

This is not desirable because it is not said that you always need all the sums 
for
all the properties of your bean, so you don't want to waste time to compute 
values
you are not interested in.

Original comment by mario.fu...@gmail.com on 3 Nov 2009 at 4:06