Subject: | isa quote_sub slower than a regular sub |
I was benchmarking various OO modules and discovered that using
quote_sub for isa checks is *slower* than a regular sub. About 30%
slower. This is contrary to the advice of the docs.
The attached benchmark comes out like so:
Benchmark: timing 6000000 iterations of with_qsub, with_sub...
with_qsub: 24 wallclock secs (24.14 usr + 0.04 sys = 24.18 CPU) @
248138.96/s (n=6000000)
with_sub: 19 wallclock secs (17.87 usr + 0.01 sys = 17.88 CPU) @
335570.47/s (n=6000000)
Subject: | Foo.pm |
package Foo;
use Moo;
use Sub::Quote;
has with_sub => (is => 'rw', isa => sub { $_[0] =~ /^[+-]?\d+$/ });
has with_qsub => (is => 'rw', isa => quote_sub q{ $_[0] =~ /^[+-]?\d+$/ });
1;
Subject: | test.plx |
Message body not shown because it is not plain text.