in reply to Re^7: list of four digit lock combinations without repeated digits
in thread list of four digit lock combinations without repeated digits
perl -MBenchmark=:all -MAlgorithm::Combinatorics=:all -wle' for ("1".."4") { my $t0 = Benchmark->new; my $i = variations_with_repetition(["a".."z"],$ARGV[0]); my @x; push @x, pack "(A*)*", @$_ while $_=$i->next; my $t1 = Benchmark->new; my $ts = timestr(timediff($t1,$t0)); print $ts }' 4
1 wallclock secs ( 0.77 usr + 0.01 sys = 0.78 CPU) 1 wallclock secs ( 0.77 usr + 0.01 sys = 0.78 CPU) 1 wallclock secs ( 0.75 usr + 0.00 sys = 0.75 CPU) 1 wallclock secs ( 0.75 usr + 0.01 sys = 0.76 CPU)
perl -MBenchmark=:all -MAlgorithm::Combinatorics=:all -wle' for ("1".."4") { my $t0 = Benchmark->new; my $i = variations_with_repetition(["a".."z"],$ARGV[0]); my @x; push @x, pack "A*", qq[@$_] while $_=$i->next; my $t1 = Benchmark->new; my $ts = timestr(timediff($t1,$t0)); print $ts }' 4
0 wallclock secs ( 0.74 usr + 0.01 sys = 0.75 CPU) 1 wallclock secs ( 0.72 usr + 0.01 sys = 0.73 CPU) 1 wallclock secs ( 0.73 usr + 0.00 sys = 0.73 CPU) 1 wallclock secs ( 0.74 usr + 0.01 sys = 0.75 CPU)
perl -MBenchmark=:all -MAlgorithm::Combinatorics=:all -wle' for ("1".."4") { my $t0 = Benchmark->new; my $i = variations_with_repetition(["a".."z"],$ARGV[0]); my @x; push @x, join "", @$_ while $_=$i->next; my $t1 = Benchmark->new; my $ts = timestr(timediff($t1,$t0)); print $ts }' 4
1 wallclock secs ( 0.65 usr + 0.01 sys = 0.66 CPU) 1 wallclock secs ( 0.64 usr + 0.00 sys = 0.64 CPU) 0 wallclock secs ( 0.63 usr + 0.00 sys = 0.63 CPU) 1 wallclock secs ( 0.64 usr + 0.01 sys = 0.65 CPU)BTW, that is one seriously quick machine you're running. What is it?
MacBook Pro i7 3.1GHz (4.1GHz Turbo Boost) 16GB RAM 1TB SSD Darwin 10.13.4
|
|---|