Do you know where your variables are? | |
PerlMonks |
Re: High Performance Game of Lifeby eyepopslikeamosquito (Archbishop) |
on Aug 12, 2017 at 07:15 UTC ( [id://1197294]=note: print w/replies, xml ) | Need Help?? |
In Fastest way to lookup a point in a set we concluded, in isolation, that hash lookups were faster using split/join rather than pack/unpack. With nothing to lose though, I tried changing split /:/, $z to unpack 'ii', $z and to: ... and almost fell off my chair when the run time for three million cells dropped from 287 seconds way down to 204 seconds!! What gives? As shown below, there is no difference in the number of op codes:
There didn't appear to be any significant difference in memory consumption either. Anyone got any ideas? The slowdown may be caused by split using a /:/ regex - and regexes are slow. Note that in Fastest way to lookup a point in a set, we were measuring lookups in isolation and lookups use join, not split. How to investigate further? Devel::NYTProf? Update:: From running: we see: That is, pack/unpack always has a hash key length of 8 bytes, while with split/join the key length varies, depending on the size of the x and y coordinates. Update: As discovered by marioroy, 'i2' is faster than 'ii' in pack and unpack.
In Section
Meditations
|
|