http://www.perlmonks.org?node_id=1231163

rsFalse has asked for the wisdom of the Perl Monks concerning the following question:

Hello.

Yesterday I was comparing pairs of arrays of integers (0 < x < 1e9), if they contain the same multiset of integers. Every pair consisted of arrays of the same size, so before comparison I sorted them alphabetically (numeric sort subroutine seems to be redundant here).

Firstly, I tried to compare by smartmatch '~~' operator, as I thought it could be the fastest implemented way.
@{ $h{ $key } } ~~ @{ $g{ $key } } and ... ;
Secondly, I compared arrays by string equality, by interpolating upto-9-digit integers into strings.
"@{ $h{ $key } }" eq "@{ $g{ $key } }" and ... ;
The second way have shown ~1.6x faster times.

Shouldn't smartmatch outrun string interpolation at that task? And which methods are fastest to accomplish comparison?