Make it 13x faster by making the code unreadable #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also, potentially up to 39x faster using the recommendation below.
Every single change in this commit actually had a positive impact on
the performance. It is sad that one has to use nqp for everything to
get things working reasonably fast.
By all means do not use .min method in your user code if you want to
get every last drop of performance. At this point everything you do
outside of Sift4 module will have a much bigger impact on the
performance.
For example, this is insanely slow:
And this is twice faster:
my $ans = ‘default value’;
my $ans-min = 6;
One would think that in the code above
sift4($_, $str, 5, 5)can bechanged to
sift4($_, $str, 5, $ans-min), but no, for some reason itdoes not work. Whether it is an issue in this implementation or in the
algorithm itself I don't know. Should be investigated I think.
Anyway, to make it easier for the users I think this module should
provide a function for processing an array (so that users are less
likely to screw it up).
Random testing suggests that these changes do not affect
functionality.