Algorithm-Permute
view release on metacpan or search on metacpan
fastest way of doing permutation among others.
COMPARISON
I've collected some Perl routines and modules which implement
permutation, and do some simple benchmark. The whole result is the
following.
Permutation of eight scalars:
Abigail's : 9 wallclock secs ( 8.07 usr + 0.30 sys = 8.37 CPU)
Algorithm::Permute : 5 wallclock secs ( 5.72 usr + 0.00 sys = 5.72 CPU)
Algorithm::Permute qw(permute): 2 wallclock secs ( 1.65 usr + 0.00 sys = 1.65 CPU)
List::Permutor : 27 wallclock secs (26.73 usr + 0.01 sys = 26.74 CPU)
Memoization : 32 wallclock secs (32.55 usr + 0.02 sys = 32.57 CPU)
perlfaq4 : 36 wallclock secs (35.27 usr + 0.02 sys = 35.29 CPU)
Permutation of nine scalars (the Abigail's routine is commented out,
because it stores all of the result in memory, swallows all of my
machine's memory):
Algorithm::Permute : 43 wallclock secs ( 42.93 usr + 0.04 sys = 42.97 CPU)
Algorithm::Permute qw(permute): 15 wallclock secs ( 14.82 usr + 0.00 sys = 14.82 CPU)
List::Permutor : 227 wallclock secs (226.46 usr + 0.22 sys = 226.68 CPU)
Memoization : 307 wallclock secs (306.69 usr + 0.43 sys = 307.12 CPU)
perlfaq4 : 272 wallclock secs (271.93 usr + 0.33 sys = 272.26 CPU)
The benchmark script is included in the bench directory. I understand
that speed is not everything. So here is the list of URLs of the
alternatives, in case you hate this module.
* Memoization is discussed in chapter 4 Perl Cookbook, so you can get
it from O'Reilly:
ftp://ftp.oreilly.com/published/oreilly/perl/cookbook
* Abigail's: http://www.foad.org/~abigail/Perl
lib/Algorithm/Permute.pm view on Meta::CPAN
=back
=head1 COMPARISON
I've collected some Perl routines and modules which implement permutation,
and do some simple benchmark. The whole result is the following.
Permutation of B<eight> scalars:
Abigail's : 9 wallclock secs ( 8.07 usr + 0.30 sys = 8.37 CPU)
Algorithm::Permute : 5 wallclock secs ( 5.72 usr + 0.00 sys = 5.72 CPU)
Algorithm::Permute qw(permute): 2 wallclock secs ( 1.65 usr + 0.00 sys = 1.65 CPU)
List::Permutor : 27 wallclock secs (26.73 usr + 0.01 sys = 26.74 CPU)
Memoization : 32 wallclock secs (32.55 usr + 0.02 sys = 32.57 CPU)
perlfaq4 : 36 wallclock secs (35.27 usr + 0.02 sys = 35.29 CPU)
Permutation of B<nine> scalars (the Abigail's routine is commented out, because
it stores all of the result in memory, swallows all of my machine's memory):
Algorithm::Permute : 43 wallclock secs ( 42.93 usr + 0.04 sys = 42.97 CPU)
Algorithm::Permute qw(permute): 15 wallclock secs ( 14.82 usr + 0.00 sys = 14.82 CPU)
List::Permutor : 227 wallclock secs (226.46 usr + 0.22 sys = 226.68 CPU)
Memoization : 307 wallclock secs (306.69 usr + 0.43 sys = 307.12 CPU)
perlfaq4 : 272 wallclock secs (271.93 usr + 0.33 sys = 272.26 CPU)
The benchmark script is included in the bench directory. I understand that
speed is not everything. So here is the list of URLs of the alternatives, in
case you hate this module.
=over 4
=item *
Memoization is discussed in chapter 4 Perl Cookbook, so you can get it from
macro. Just C<#define> the macro before including C<ppport.h>:
#define DPPP_NAMESPACE MyOwnNamespace_
#include "ppport.h"
The default namespace is C<DPPP_>.
=back
The good thing is that most of the above can be checked by running
F<ppport.h> on your source code. See the next section for
details.
=head1 EXAMPLES
To verify whether F<ppport.h> is needed for your module, whether you
should make any changes to your code, and whether any special defines
should be used, F<ppport.h> can be run as a Perl script to check your
source code. Simply say:
perl ppport.h
_add_range_to_invlist|||
_append_range_to_invlist|||
_core_swash_init|||
_get_encoding|||
_get_regclass_nonbitmap_data|||
_get_swash_invlist|||
_invlistEQ|||
_invlist_array_init|||n
_invlist_contains_cp|||n
_invlist_dump|||
_invlist_intersection_maybe_complement_2nd|||
_invlist_intersection|||
_invlist_invert|||
_invlist_len|||n
_invlist_populate_swatch|||n
_invlist_search|||n
_invlist_subtract|||
_invlist_union_maybe_complement_2nd|||
_invlist_union|||
_is_cur_LC_category_utf8|||
_is_in_locale_category||5.021001|
_is_uni_FOO||5.017008|
sortsv||5.007003|
space_join_names_mortal|||
ss_dup|||
ssc_add_range|||
ssc_and|||
ssc_anything|||
ssc_clear_locale|||n
ssc_cp_and|||
ssc_finalize|||
ssc_init|||
ssc_intersection|||
ssc_is_anything|||n
ssc_is_cp_posixl_init|||n
ssc_or|||
ssc_union|||
stack_grow|||
start_glob|||
start_subparse||5.004000|
stdize_locale|||
strEQ|||
strGE|||
* data from C. All statics in extensions should be reworked to use
* this, if you want to make the extension thread-safe. See ext/re/re.xs
* for an example of the use of these macros.
*
* Code that uses these macros is responsible for the following:
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* MY_CXT.member.
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
#ifndef START_MY_CXT
( run in 0.740 second using v1.01-cache-2.11-cpan-39bf76dae61 )