Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
RFC extending Benchmark.pm to facilitate CODEHASHREFby LanX (Saint) |
on Nov 25, 2013 at 22:30 UTC ( [id://1064322]=perlmeditation: print w/replies, xml ) | Need Help?? |
Hi I never liked the usage of the CODEHASHREF in Benchmark. Often people start writing things like
which isn't very DRY and makes experimenting with optimizations really cumbersome! (I hate it, every new function name has to be repeated 3 times in different locations...) see also Re: Best method to diff very large array efficiently for another examle. My idea is to put all subs into a dedicated package (defaultname "CMP" or so) and to automatically filter necessary name and coderefs.
ATM I'm using a function pckg_subs() for this, not sure if it makes sense to extend the interface of cmpthese and timethese to directly accept a stash-ref like \%CMP::. ¹ Following a proof on concept, request for comments. OUTPUT
The idea code be extended with sub-attribute ':compare' or ':nocompare' to additionally mark functions which are supposed to be compared or not.
Cheers Rolf ( addicted to the Perl Programming Language) update¹) is it possible to tell if a hashref belongs to a stash? ... well at least I could parse %main or pass the packagename directly =)
Back to
Meditations
|
|