NAME
Number::Iterator::XS - iterate numbers faster
VERSION
Version 0.04
SYNOPSIS
use Number::Iterator::XS;
my $iter = Number::Iterator::XS->new(interval => 50);
$iter++;
$iter--;
print "$iter";
METHODS
new
Instantiate a new Number::Iterator object.
my $iter = Number::Iterator::XS->new(
interval => 50,
iterate => sub {
my ($self) = @_;
($self->{value} ||= 1) *= $self->{interval};
},
deiterate => sub {
my ($self) = @_;
$self->{value} /= $self->{interval};
}
);
iterate
$iter++;
$iter->iterate;
deiterate
$iter--;
$iter->deiterate;
value
"$iter";
$iter->value;
interval
$iter->interval;
$iter->interval(50);
BENCHMARK
use Benchmark qw(:all);
use Number::Iterator;
use Number::Iterator::XS;
timethese(10000000, {
'Iterator' => sub {
my $n = Number::Iterator->new(interval => 20);
$n++;
$n--;
$n->value;
},
'XS' => sub {
my $n = Number::Iterator::XS->new(interval => 20);
$n++;
$n--;
$n->value;
}
});
...
Benchmark: timing 10000000 iterations of Iterator, XS...
Iterator: 8 wallclock secs ( 7.56 usr + 0.00 sys = 7.56 CPU) @ 1322751.32/s (n=10000000)
XS: 4 wallclock secs ( 5.14 usr + 0.06 sys = 5.20 CPU) @ 1923076.92/s (n=10000000)
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-number-iterator-xs at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Number-Iterator-XS. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Number::Iterator::XS
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Number-Iterator-XS
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2024 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)