Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Special case mktime: semi-sequential accessby flexvault (Monsignor) |
on Jun 30, 2013 at 19:40 UTC ( [id://1041638]=note: print w/replies, xml ) | Need Help?? |
Welcome not_japh, The hypothesis appears confirmed by some benchmarking of 1e7 (sequential!) dates: Originally I looked at this and thought that this is a job for 'use Memoize;', but then I thought if the inputs are sequential, maybe it's a real time program and once a second changes, you never go back. This is an alternate approach with-out the calculations.
Obviously '$savetime' and '$saveinput' needs to be defined for global use. On most modern computers you can call a small subroutine like this hundreds of thousands times per second, and each time the cached time will be used. Personally, what I like is that you're using caching to improve the performance of the script. That technique will help you lots of times in the future. Good Luck...Ed "Well done is better than well said." - Benjamin Franklin
In Section
Seekers of Perl Wisdom
|
|