# [rrd-users] Re: problems summing many sources together

Alex van den Bogaerdt alex at ergens.op.het.net
Thu Jun 8 01:15:33 MEST 2006

```On Wed, Jun 07, 2006 at 06:19:52PM +0200, Georges Toth wrote:

> First one is to define 21 times this:
> 	CDEF:in_1=in1,UN,0,in1,IF
> 	CDEF:out_1=out1,UN,0,out1,IF
> and then sum it like this:
> 	CDEF:intot=in_1,in_2,+,in_3,+,in_4,+,in_5,+,in_6,+,in_7,+,in_8,+,in_9,
> +,in_10,+,in_11,+,in_12,+,in_13,+,in_14,+,in_15,+,in_16,+,in_17,+,in_18,
> +,in_19,+,in_20,+,in_21,+
> 	CDEF:outtot=out_1,out_2,+,out_3,+,out_4,+,out_5,+,out_6,+,out_7,+,out_8,
> +,out_9,+,out_10,+,out_11,+,out_12,+,out_13,+,out_14,+,out_15,+,out_16,
> +,out_17,+,out_18,+,out_19,+,out_20,+,out_21,+

This creates 44 extra arrays containing ranges.

> Second one was like you suggested (but I only read that when I already tried
> the first one...):
>
> CDEF:intot=in1,UN,0,in1,IF,in1,UN,0,in1,IF,in2,UN,0,in2,IF,in3,UN,0,in3,IF,in4,UN,0,in4,IF,in5,UN,0,in5,IF,in6,UN,0,in6,IF,in7,UN,0,in7,IF,in8,UN,0,in8,IF,in9,UN,0,in9,IF,in10,UN,0,in10,IF,in11,UN,0,in11,IF,in12,UN,0,in12,IF,in13,UN,0,in13,IF,in14,UN,0,in14,IF,in15,UN,0,in15,IF,in16,UN,0,in16,IF,in17,UN,0,in17,IF,in18,UN,0,in18,IF,in19,UN,0,in19,IF,in20,UN,0,in20,IF,in21,UN,0,in21,IF,
> +,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+
> CDEF:outtot=out1,UN,0,out1,IF,out2,UN,0,out2,IF,out3,UN,0,out3,IF,out4,UN,0,out4,IF,out5,UN,0,out5,IF,out6,UN,0,out6,IF,out7,UN,0,out7,IF,out8,UN,0,out8,IF,out9,UN,0,out9,IF,out10,UN,0,out10,IF,out11,UN,0,out11,IF,out12,UN,0,out12,IF,out13,UN,0,out13,IF,out14,UN,0,out14,IF,out15,UN,0,out15,IF,out16,UN,0,out16,IF,out17,UN,0,out17,IF,out18,UN,0,out18,IF,out19,UN,0,out19,IF,out20,UN,0,out20,IF,out21,UN,0,out21,IF,
> +,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+,+

This creates two extra arrays containing ranges.

> I'm wondering which one is better / faster ?

If your system is low on memory and will have to use swap space, I bet
the first mentioned way will be much slower.

On the other hand, if you hit a limit in your operating system, where
lines become too long, you may have to do your adding in at least a
couple of steps.

In other words: it depends.  How memory is accessed may also proove to
be a factor.  Just try it.  If you don't notice a difference, you need
not care.  If you do notice a difference, you have your answer.

> Also, is there no more efficient solution for doing this ?

How much is 1 plus 2 plus unknown plus 4 plus 5 ?

There is only one answer: unknown.

If you want something special, you need to do some work.  I don't see
how you can reduce the amount of work needed right now.

--
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users