in reply to PDL vs C speed question
For 10,000 datapoints I was getting 6 seconds for C code and 340 seconds for the perl.
sub sum { my $a = shift; $a + $a; } my @data; for (0..10000) { push(@data, 3.1415926 * $_); } for ($i = 0; $i < @data; $i++){ for ($j = $i + 1; $j < @data; $j++){ sum($data[$i] * $data[$j]); } } __END__ #include <limits.h> double test(double x) { return x + x; } #define SIZE 10000 main() { int i, j; double data[SIZE]; int x; for (x = 0; x < SIZE; x++) { data[x] = 3.1415926 * x; } for (i = 0; i < SIZE; i++){ for (j = 0; j < SIZE; j++){ test(data[i] * data[j]); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: PDL vs C speed question
by glwtta (Hermit) on May 06, 2005 at 03:50 UTC |