File: bm.pl

package info (click to toggle)
libmath-int128-perl 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 604 kB
  • sloc: perl: 2,614; ansic: 340; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 801 bytes parent folder | download
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
37
#!/usr/bin/perl

use 5.010;

use strict;
use warnings;

use Benchmark qw(cmpthese);

use Math::GMP;
use Math::GMPz;
use Math::Int128 qw(int128);

sub bigrand { join "", (1..9)[rand 9], map { (0..9)[rand 10] } 0..33 }

my @data = map bigrand(), 0..1000;



my @int128 = map int128($_), @data;
my @gmp = map Math::GMP->new($_), @data;
my @gmpz = map Math::GMPz->new($_), @data;

cmpthese(-1, { int128 => sub {
                   my $i;
                   $i = ($_ + (1 + $_)) / (10 + $_) for @int128
               },
               gmp => sub {
                   my $i;
                   $i = ($_ + (1 + $_)) / (10 + $_) for @gmp
               },
               gmpz => sub {
                   my $i;
                   $i = ($_ + (1 + $_)) / (10 + $_) for @gmpz
               }
             });