<commit_before>use strict;
use warnings;

use Ref::Util qw<is_arrayref is_plain_arrayref is_plain_hashref>;
use Scalar::Util ();
use Dumbbench;

my $bench = Dumbbench->new(
    target_rel_precision => 0.005, # seek ~0.5%
    initial_runs         => 20,    # the higher the more reliable
);

my $ref = [];
no warnings;
$bench->add_instances(
    Dumbbench::Instance::PerlSub->new(
        name => 'Ref::Util',
        code => sub { Ref::Util::is_plain_arrayref($ref) for ( 1 .. 1e5 ) },
    ),

    Dumbbench::Instance::PerlSub->new(
        name => 'proper reftype()',
        code => sub {
            ref $ref
                && Scalar::Util::reftype($ref) eq 'ARRAY'
                && !Scalar::Util::blessed($ref)
                for ( 1 .. 1e5 );
        },
    ),

    Dumbbench::Instance::PerlSub->new(
        name => 'simple ref()',
        code => sub { ref($ref) eq 'ARRAY' for ( 1 .. 1e7 ) },
    ),
);

$bench->run;
$bench->report;<commit_msg>add Data::Util to benchmark check<commit_after>use strict;
use warnings;

use Ref::Util qw<is_arrayref is_plain_arrayref is_plain_hashref>;
use Scalar::Util ();
use Data::Util ':check';
use Dumbbench;

my $bench = Dumbbench->new(
    target_rel_precision => 0.005, # seek ~0.5%
    initial_runs         => 20,    # the higher the more reliable
);

my $ref = [];
no warnings;
$bench->add_instances(
    Dumbbench::Instance::PerlSub->new(
        name => 'Ref::Util',
        code => sub { Ref::Util::is_plain_arrayref($ref) for ( 1 .. 1e5 ) },
    ),

    Dumbbench::Instance::PerlSub->new(
        name => 'proper reftype()',
        code => sub {
            ref $ref
                && Scalar::Util::reftype($ref) eq 'ARRAY'
                && !Scalar::Util::blessed($ref)
                for ( 1 .. 1e5 );
        },
    ),

    Dumbbench::Instance::PerlSub->new(
        name => 'simple ref()',
        code => sub { ref($ref) eq 'ARRAY' for ( 1 .. 1e5 ) },
    ),

    Dumbbench::Instance::PerlSub->new(
        name => 'Data::Util',
        code => sub { is_array_ref($ref) for ( 1 .. 1e5 ) },
    ),

);

$bench->run;
$bench->report;
{'fraction_non_alphanumeric': 0.17461832061068702, 'fraction_numerical': 0.017652671755725192, 'mean_word_length': 2.360576923076923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6460831', 'n_tokens_mistral': 756, 'n_tokens_neox': 711, 'n_words': 155}