File: Bench.pm

package info (click to toggle)
pdl 1%3A2.100-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,816 kB
  • sloc: perl: 22,587; ansic: 14,969; sh: 31; makefile: 30; sed: 6
file content (36 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Old results: approx. 1.91_03: 34 secs (512, 10 iter)
# With simply folded-out broadcasting: 3.4 secs (10fold!)

# For 512,30iter:

package PDL::Bench;

use strict;
use warnings;
require Exporter;
require DynaLoader;

our @ISA = qw(Exporter DynaLoader);
our @EXPORT = qw(
	do_benchmark
);

bootstrap PDL::Bench;

use Benchmark;

sub do_benchmark {
	$size = 512;
	$niter = 10000;
	$ndarray = (PDL->zeroes($size,$size));
	$dref = ${$ndarray->get_dataref()};
	timethese($niter, {
#		'With double ndarray' => 'for($i=0; $i<100; $i++) {$ndarray++}',
		'With double ndarray' => '$ndarray++;',
		'C using ++' => 'c_use_pp($dref)',
		'C using foo = bar + baz' => 'c_use_add($dref,$dref,$dref)',
		'C using incrs and foo = bar + baz' => 'c_use_add_incr($dref,$dref,$dref,1,1,1)'
	});
}

1;