[Lemon-devel] Strange running time results
Alpár Jüttner
alpar at cs.elte.hu
Wed Jun 27 10:27:20 CEST 2007
Hi,
I compiled the code you can see below. I used g++-4.1.2 with
optimization flag -O2. The attached picture shows the running times of
the iterations.
Could anyone explain that strange "forking" tendency in the running
times?
Regards,
Alpar
#include <lemon/time_measure.h>
#include <iostream>
double mpower_sum(int size,double *m)
{
double s=0;
for(int i=0;i<size;i++)
for(int j=0;j<size;j++)
for(int k=0;k<size;k++)
s+=m[i*size+k]*m[k*size+j];
return s;
}
int main(int argc,char **argv)
{
int size=1000;
int step=10;
double *m = (double *)malloc(sizeof(double)*(size*size+3));
for(int i=0;i<size*size;i++) m[i]=i;
for(int i=step;i<=size;i+=step)
{
lemon::Timer t;
mpower_sum(i,m);
std::cout << i << ' ' << t.realTime() << std::endl;
}
free(p);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpower.cc
Type: text/x-c++src
Size: 1425 bytes
Desc: not available
URL: <http://lemon.cs.elte.hu/pipermail/lemon-devel/attachments/20070627/838d37ad/attachment.cc>
More information about the Lemon-devel
mailing list