- or download this
use Benchmark qw(:all) ;
...
'eq' => sub { lc $value eq "true" },
'index' => sub { index( lc $value, "true" ) >= 0 },
});
- or download this
Benchmark: timing 1000000 iterations of eq, index, regex...
eq: 1 wallclock secs ( 0.89 usr + 0.00 sys = 0.89 CPU) @ 11
+23595.51/s (n=1000000)
...
index 606061/s -- -1% -46%
regex 613497/s 1% -- -45%
eq 1123596/s 85% 83% --
- or download this
'regex' => sub { $value =~ /true/i },
'regex_anch' => sub { $value =~ /^true$/i },
'eq' => sub { lc $value eq "true" },
'index' => sub { index( lc $value, "true" ) >= 0 },
- or download this
Benchmark: timing 1000000 iterations of eq, index, regex, regex_anch..
+.
eq: 1 wallclock secs ( 0.88 usr + 0.00 sys = 0.88 CPU) @ 11
+36363.64/s (n=1000000)
...
regex_anch 628931/s 4% -- -32% -45%
regex 925926/s 53% 47% -- -19%
eq 1136364/s 87% 81% 23% --