Zentara, could you provide me with the command  you
used to find out cpu time and mem so I can run
a similar test and compare with your results?

 Thanks,

 Xavier Calbet

On 1/11/07, zentara <[EMAIL PROTECTED]> wrote:
On Tue, 09 Jan 2007 12:29:44 +0100
Bruno Picard <[EMAIL PROTECTED]> wrote:

>A kind of newbie question to start well 2007.
>I've looked for some comparison between C and PDL
>(and/or Fortran or else) throught the web but I haven't found
>any documentation about comparison in term of memory and/or
>cpu time consuming.
>
>Does anyone have some inputs on this question?
>
>regards,
>Bruno

Hi, this sort of interested me too, so I made a couple of programs
that you can run yourself, to test.

I have a 2Ghz Athlon, and 1 Gig ram, so your results may
vary, and the scripts may need to be modified.

The idea is to make an array of 50,000,000 doubles, and
cycle thru them 10 times to increment them.

The C program and the Perl-PDL program were very close
on my system, at about 10 secs, and 480 Megs of ram used.

Of course the c program may be poorly written, (maybe it would be
faster to cycle thru with an array pointer? ), but I only understand the
basics of C.

The pure Perl program, was limited to 10,000,000 floats, since it
uses 5 times as much memory to store variables. Also the smaller
pure Perl program takes at least double the time of PDL.

So when you consider all the other things which PDL makes convenient,
like IO, graphing, dimensional munging, etc. it definitely stands up well.

The C program:  gcc -o test test.c
#include <stdio.h>
#include <stdlib.h>

/* Declare a 1-dimensional array with 50 million doubles */
double darray[50000000];
long a;
int b;

main(){
for (a = 0; a < 50000000; a++){
      darray[a]= a;
   }

for (b = 0; b < 10; b++){
  for (a = 0; a < 50000000; a++){
         darray[a]++;
     }
}

printf("\n %f ", darray[1000000]);
printf("\nPress Enter to quit.\n");
getchar();
return 0;
}

#############################################
 the Perl/PDL program

#!/usr/bin/perl
use warnings;
use strict;
use PDL::LiteF;

$a = sequence(double,50000000);
#print dims $a,"\n";

for(1..10){
   $a++;
  }

print $a->at(1000000);
print "\n";
print "hit enter to exit\n";
<>; #allow you to check memory
__END__


############################################

the pure Perl script ( just for comparison)

#!/usr/bin/perl
use warnings;
use strict;
use Math::BigFloat;

my $x = Math::BigFloat->new(0);
my $y = Math::BigFloat->new(10000000);
my @array = ($x..$y);

for(1..10){
    map { $_++ } @array;
  }

print "$array[1000000]\n";
print "hit enter to exit\n";
<>;
__END__


zentara



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to