in reply to Re^3: Where does the spurious error message come from?
in thread Where does the spurious error message come from?
"How does it compare speed-wise ..."
A very quick benchmark shows no appreciable difference.
#!/usr/bin/env perl use strict; use warnings; use Array::Contains; use List::Util 'any'; use Benchmark 'cmpthese'; my @base = 'A' .. 'Z'; my @search = map +($_, lc), @base; print "\@base[@base]\n"; print "\@search[@search]\n"; cmpthese 0 => { lua => \&lua, acc => \&acc, }; sub lua { for my $x (@search) { my $bool = any { $_ eq $x } @base; } return; } sub acc { for my $x (@search) { my $bool = contains($x, \@base); } return; }
The check on the arrays was the same on each run:
@base[A B C ... X Y Z] @search[A a B b C c ... X x Y y Z z]
Here's the results of three runs:
Rate lua acc lua 15544/s -- -1% acc 15622/s 1% -- Rate acc lua acc 15777/s -- -1% lua 15905/s 1% -- Rate acc lua acc 15782/s -- -0% lua 15857/s 0% --
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Where does the spurious error message come from?
by choroba (Cardinal) on Aug 06, 2023 at 11:56 UTC | |
by kcott (Archbishop) on Aug 06, 2023 at 15:57 UTC |