Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Multiplication with zero (http://www.velocityreviews.com/forums/t390654-multiplication-with-zero.html)

 logiclips@yahoo.com 02-06-2007 11:55 AM

Multiplication with zero

Hi,

I'm having a dataset which I use to multiply with another dataset. The
number of multiplications is >5000 but constant.
The time for computing varies (~0.1-0.2 s) for different datasets,
although they are of the same size. What is the reason for this
variation? Is it because of the zeros that are in the dataset such
that multiplication with zero is faster than any other multiplication.
So the more zeros the faster? Or is it maybe a memory problem?

Thanks,

Peter Vermeer

 Patricia Shanahan 02-06-2007 01:31 PM

Re: Multiplication with zero

logiclips@yahoo.com wrote:
> Hi,
>
> I'm having a dataset which I use to multiply with another dataset. The
> number of multiplications is >5000 but constant.
> The time for computing varies (~0.1-0.2 s) for different datasets,
> although they are of the same size. What is the reason for this
> variation? Is it because of the zeros that are in the dataset such
> that multiplication with zero is faster than any other multiplication.
> So the more zeros the faster? Or is it maybe a memory problem?

There are all sorts of effects that could give a 0.1 second variation in
time unless you have things really well locked down.

Do repeated runs with the same dataset take the same amount of time? In
particular, try alternating runs with a "fast" and a "slow" data set.

Patricia

 logiclips@yahoo.com 02-06-2007 02:25 PM

Re: Multiplication with zero

On 6 Feb., 14:31, Patricia Shanahan <p...@acm.org> wrote:
> logicl...@yahoo.com wrote:
> > Hi,

>
> > I'm having a dataset which I use to multiply with another dataset. The
> > number of multiplications is >5000 but constant.
> > The time for computing varies (~0.1-0.2 s) for different datasets,
> > although they are of the same size. What is the reason for this
> > variation? Is it because of the zeros that are in the dataset such
> > that multiplication with zero is faster than any other multiplication.
> > So the more zeros the faster? Or is it maybe a memory problem?

>
> There are all sorts of effects that could give a 0.1 second variation in
> time unless you have things really well locked down.
>
> Do repeated runs with the same dataset take the same amount of time? In
> particular, try alternating runs with a "fast" and a "slow" data set.
>
> Patricia

Well the problem is that I have only the results of the different
datasets but I'm not able to test these anymore.
BTW the total amount of processing time is approx 3.5 sec.
Could the things mentioned above be a reason for the time variance?

 Oliver Wong 02-06-2007 04:54 PM

Re: Multiplication with zero

<logiclips@yahoo.com> wrote in message
> On 6 Feb., 14:31, Patricia Shanahan <p...@acm.org> wrote:
>> logicl...@yahoo.com wrote:
>> > Hi,

>>
>> > I'm having a dataset which I use to multiply with another dataset. The
>> > number of multiplications is >5000 but constant.
>> > The time for computing varies (~0.1-0.2 s) for different datasets,
>> > although they are of the same size. What is the reason for this
>> > variation? Is it because of the zeros that are in the dataset such
>> > that multiplication with zero is faster than any other multiplication.
>> > So the more zeros the faster? Or is it maybe a memory problem?

>>
>> There are all sorts of effects that could give a 0.1 second variation in
>> time unless you have things really well locked down.
>>

[...]
>
> Could the things mentioned above be a reason for the time variance?

Yes.

- Oliver

 Greg R. Broderick 02-06-2007 07:59 PM

Re: Multiplication with zero

logiclips@yahoo.com wrote in

> On 6 Feb., 14:31, Patricia Shanahan <p...@acm.org> wrote:
>> logicl...@yahoo.com wrote:
>> > Hi,

>>
>> > I'm having a dataset which I use to multiply with another
>> > dataset. The number of multiplications is >5000 but constant.
>> > The time for computing varies (~0.1-0.2 s) for different
>> > datasets, although they are of the same size. What is the reason
>> > for this variation? Is it because of the zeros that are in the
>> > dataset such that multiplication with zero is faster than any
>> > other multiplication. So the more zeros the faster? Or is it
>> > maybe a memory problem?

>>
>> There are all sorts of effects that could give a 0.1 second
>> variation in time unless you have things really well locked down.
>>
>> Do repeated runs with the same dataset take the same amount of
>> time? In particular, try alternating runs with a "fast" and a
>> "slow" data set.
>>
>> Patricia

>
> Well the problem is that I have only the results of the different
> datasets but I'm not able to test these anymore.
> BTW the total amount of processing time is approx 3.5 sec.

If you're trying to significantly speed up that 3.5 seconds, then I'd
suggest that attempting to optimize an operation that will, at best,
result in a 0.2 second improvement is a less-than-optimal use of your
time -- there are undoubtedly other optimizations that could result in
greater speed improvement.

Cheers
GRB

 logiclips@yahoo.com 02-07-2007 10:43 AM

Re: Multiplication with zero

On 6 Feb., 20:59, "Greg R. Broderick" <gregb
+usenet200...@blackholio.dyndns.org> wrote:
>
>
>
> > On 6 Feb., 14:31, Patricia Shanahan <p...@acm.org> wrote:
> >> logicl...@yahoo.com wrote:
> >> > Hi,

>
> >> > I'm having a dataset which I use to multiply with another
> >> > dataset. The number of multiplications is >5000 but constant.
> >> > The time for computing varies (~0.1-0.2 s) for different
> >> > datasets, although they are of the same size. What is the reason
> >> > for this variation? Is it because of the zeros that are in the
> >> > dataset such that multiplication with zero is faster than any
> >> > other multiplication. So the more zeros the faster? Or is it
> >> > maybe a memory problem?

>
> >> There are all sorts of effects that could give a 0.1 second
> >> variation in time unless you have things really well locked down.

>
> >> Do repeated runs with the same dataset take the same amount of
> >> time? In particular, try alternating runs with a "fast" and a
> >> "slow" data set.

>
> >> Patricia

>
> > Well the problem is that I have only the results of the different
> > datasets but I'm not able to test these anymore.
> > BTW the total amount of processing time is approx 3.5 sec.

>
> If you're trying to significantly speed up that 3.5 seconds, then I'd
> suggest that attempting to optimize an operation that will, at best,
> result in a 0.2 second improvement is a less-than-optimal use of your
> time -- there are undoubtedly other optimizations that could result in
> greater speed improvement.
>
> Cheers
> GRB

Actually I don't want to speed it up. I just want to know why these
variations exist although the operations are always the same.

Thanks,
Peter

 pascal.lecointe@euriware.fr 02-07-2007 12:21 PM

Re: Multiplication with zero

On 7 fév, 11:43, logicl...@yahoo.com wrote:
> On 6 Feb., 20:59, "Greg R. Broderick" <gregb
>
>
>
> +usenet200...@blackholio.dyndns.org> wrote:
> > logicl...@yahoo.com wrote innews:1170771926.519649.217370@a34g2000cwb.google groups.com:

>
> > > On 6 Feb., 14:31, Patricia Shanahan <p...@acm.org> wrote:
> > >> logicl...@yahoo.com wrote:
> > >> > Hi,

>
> > >> > I'm having a dataset which I use to multiply with another
> > >> > dataset. The number of multiplications is >5000 but constant.
> > >> > The time for computing varies (~0.1-0.2 s) for different
> > >> > datasets, although they are of the same size. What is the reason
> > >> > for this variation? Is it because of the zeros that are in the
> > >> > dataset such that multiplication with zero is faster than any
> > >> > other multiplication. So the more zeros the faster? Or is it
> > >> > maybe a memory problem?

>
> > >> There are all sorts of effects that could give a 0.1 second
> > >> variation in time unless you have things really well locked down.

>
> > >> Do repeated runs with the same dataset take the same amount of
> > >> time? In particular, try alternating runs with a "fast" and a
> > >> "slow" data set.

>
> > >> Patricia

>
> > > Well the problem is that I have only the results of the different
> > > datasets but I'm not able to test these anymore.
> > > BTW the total amount of processing time is approx 3.5 sec.

>
> > If you're trying to significantly speed up that 3.5 seconds, then I'd
> > suggest that attempting to optimize an operation that will, at best,
> > result in a 0.2 second improvement is a less-than-optimal use of your
> > time -- there are undoubtedly other optimizations that could result in
> > greater speed improvement.

>
> > Cheers
> > GRB

>
> Actually I don't want to speed it up. I just want to know why these
> variations exist although the operations are always the same.
>
> Thanks,
> Peter

If you are on windows, the resolution of the timer is about of 10 ms ,
unless you use the new System.nanoTime(), which resolution is much
finer, perhaps it's a problem of resolution of timer (for 0.1 - 0.2
sec, it's probably not the cause).

If the program use a database connection to retrieve the dataset,
perhaps the network or the database is busy during your test

The system is perhaps running another processes which use the CPU in
the same time