File: speed

package info (click to toggle)
libmath-gsl-perl 0.45-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 192,156 kB
  • sloc: ansic: 895,524; perl: 24,682; makefile: 12
file content (23 lines) | stat: -rwxr-xr-x 582 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w

use strict;
use warnings;
use Benchmark;
use Math::GSL::Vector;
use Math::GSL::RNG;
use List::Util qw/max min/;

my $rng = Math::GSL::RNG->new;
my $num = shift || 10000;
my @stuff  = map { $rng->get() } (1..$num);
my $vector = Math::GSL::Vector->new([@stuff]);

my $runs = shift || 50_000;
timethese($runs, {
    'min - List::Util         ' => sub { min(@stuff) },
    'min of Math::GSL vector  ' => sub { $vector->min },
});
timethese($runs, {
    'max - List::Util         ' => sub { max(@stuff) },
    'max of Math::GSL vector  ' => sub { $vector->max },
});