At first, I experimented with Sort::Key module , because sorting takes longer than just looping and typing. Also, if the internal hash keys are (basically) identical, then you should just pre-empt them, but I assume that it is not, otherwise you will already do it.
Obviously, you should try to assign the $ signal_db {$ loop} link. You may find that each faster than keys plus a search, especially if used with Sort::Key . I would check if the card works faster than foreach , maybe the same thing, but who knows. You might find that print is faster if you pass it a list or call it several times.
I have not tried this code, but threw away all these ideas, except each gives:
foreach my $cycle (nsort keys %signal_db) { my $r = $signal_db{$cycle}; map { print ($r->{$_},$_,"\n"); } (nsort keys %$r); }
There is an article on perl sorting here , check out the Schwartz transform if you want to see how each can be used.
If your code does not have to be safe, then you could disable Perl protection against algorithmic complexity attacks by setting PERL_HASH_SEED or related variables and / or recompiling Perl with the changed settings, so that the perl keys and values commands returned the keys or values โโin sorted order already, thus saving you considerable time sorting them. But before that, check out this 28C3 talk . I don't know, even if this works, you will need to read this part of the Perl source code, maybe just implement your loop in C.
source share