Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 24 lines (20 sloc) 0.584 kb
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 },
});
Something went wrong with that request. Please try again.