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.
Shouldn't smartmatch outrun string interpolation at that task? And which methods are fastest to accomplish comparison?
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.
Secondly, I compared arrays by string equality, by interpolating upto-9-digit integers into strings.@{ $h{ $key } } ~~ @{ $g{ $key } } and ... ;
The second way have shown ~1.6x faster times."@{ $h{ $key } }" eq "@{ $g{ $key } }" and ... ;
Shouldn't smartmatch outrun string interpolation at that task? And which methods are fastest to accomplish comparison?
Back to
Seekers of Perl Wisdom