Algorithm-LUHN_XS

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


DESCRIPTION
    This module is an XS version of the original Perl Module
    Algorithm::LUHN, which was written by Tim Ayers. It should work exactly
    the same, only substantially faster. The supplied check_digit() routine
    is 100% compatible with the pure Perl Algorithm::LUHN module, while the
    faster check_digit_fast() and really fast check_digit_rff() are not.

    How much faster? Here's a benchmark, running on a 3.4GHz i7-2600:

    "Benchmark: timing 100 iterations"

    "Algorithm::LUHN: 69 secs (69.37 usr 0.00 sys) 1.44/s"

    "check_digit: 2 secs ( 1.98 usr 0.00 sys) 50.51/s"

    "check_digit_fast: 2 secs ( 1.68 usr 0.00 sys) 59.52/s"

    "check_digit_rff: 1 secs ( 1.29 usr 0.00 sys) 77.52/s"

    So, it's 35x to 53x faster than the original pure Perl module, depending

README  view on Meta::CPAN

            is_valid('4242424242424242');   # true
            is_valid('4242424242424243');   # false

    is_valid_fast CHECKSUMMED_NUM
    is_valid_rff CHECKSUMMED_NUM
        As with check_digit(), we have 3 versions of is_valid(), each one
        progressively faster than the check_digit() that comes in the
        original pure Perl Algorithm::LUHN module. Here's a benchmark of 1M
        total calls to is_valid():

        "Benchmark: timing 100 iterations"

        "Algorithm::LUHN: 100 secs (100.29 usr 0.01 sys) 1.00/s"

        "is_valid: 3 secs ( 2.46 usr 0.11 sys) 38.91/s"

        "is_valid_fast: 2 secs ( 2.38 usr 0.05 sys) 41.15/s"

        "is_valid_rff: 2 secs ( 1.97 usr 0.08 sys) 48.78/s"

        Algorithm::LUHN_XS varies from 38x to 48x times faster than the

README.md  view on Meta::CPAN

# DESCRIPTION

This module is an XS version of the original Perl Module Algorithm::LUHN, which
was written by Tim Ayers.  It should work exactly the same, only substantially
 faster. The supplied check\_digit() routine is 100% compatible with the pure
Perl Algorithm::LUHN module, while the faster check\_digit\_fast() and really fast
check\_digit\_rff() are not. 

How much faster? Here's a benchmark, running on a 3.4GHz i7-2600:

`Benchmark: timing 100 iterations`

`Algorithm::LUHN: 69 secs (69.37 usr 0.00 sys)  1.44/s`

`check_digit:      2 secs ( 1.98 usr 0.00 sys) 50.51/s`

`check_digit_fast: 2 secs ( 1.68 usr 0.00 sys) 59.52/s`

`check_digit_rff:  1 secs ( 1.29 usr 0.00 sys) 77.52/s`

So, it's 35x to 53x faster than the original pure Perl module, depending on

README.md  view on Meta::CPAN

        is_valid('4242424242424242');   # true
        is_valid('4242424242424243');   # false

- is\_valid\_fast CHECKSUMMED\_NUM
- is\_valid\_rff CHECKSUMMED\_NUM

    As with check\_digit(), we have 3 versions of is\_valid(), each one progressively
    faster than the check\_digit() that comes in the original pure Perl 
    Algorithm::LUHN module.  Here's a benchmark of 1M total calls to is\_valid():

    `Benchmark: timing 100 iterations`

    `Algorithm::LUHN: 100 secs (100.29 usr 0.01 sys)  1.00/s`

    `is_valid:          3 secs (  2.46 usr 0.11 sys) 38.91/s`

    `is_valid_fast:     2 secs (  2.38 usr 0.05 sys) 41.15/s` 

    `is_valid_rff:      2 secs (  1.97 usr 0.08 sys) 48.78/s`

    Algorithm::LUHN\_XS varies from 38x to 48x times faster than the original

lib/Algorithm/LUHN_XS.pm  view on Meta::CPAN

=head1 DESCRIPTION

This module is an XS version of the original Perl Module Algorithm::LUHN, which
was written by Tim Ayers.  It should work exactly the same, only substantially
 faster. The supplied check_digit() routine is 100% compatible with the pure
Perl Algorithm::LUHN module, while the faster check_digit_fast() and really fast
check_digit_rff() are not. 

How much faster? Here's a benchmark, running on a 3.4GHz i7-2600:

C<Benchmark: timing 100 iterations>

C<Algorithm::LUHN: 69 secs (69.37 usr 0.00 sys)  1.44/s>

C<check_digit:      2 secs ( 1.98 usr 0.00 sys) 50.51/s>

C<check_digit_fast: 2 secs ( 1.68 usr 0.00 sys) 59.52/s>

C<check_digit_rff:  1 secs ( 1.29 usr 0.00 sys) 77.52/s>

So, it's 35x to 53x faster than the original pure Perl module, depending on

lib/Algorithm/LUHN_XS.pm  view on Meta::CPAN

=cut

=item is_valid_fast CHECKSUMMED_NUM
=cut
=item is_valid_rff CHECKSUMMED_NUM

As with check_digit(), we have 3 versions of is_valid(), each one progressively
faster than the check_digit() that comes in the original pure Perl 
Algorithm::LUHN module.  Here's a benchmark of 1M total calls to is_valid():

C<Benchmark: timing 100 iterations>

C<Algorithm::LUHN: 100 secs (100.29 usr 0.01 sys)  1.00/s>

C<is_valid:          3 secs (  2.46 usr 0.11 sys) 38.91/s>

C<is_valid_fast:     2 secs (  2.38 usr 0.05 sys) 41.15/s> 

C<is_valid_rff:      2 secs (  1.97 usr 0.08 sys) 48.78/s>

Algorithm::LUHN_XS varies from 38x to 48x times faster than the original



( run in 1.303 second using v1.01-cache-2.11-cpan-71847e10f99 )