-
-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue 1145 #1146
fix issue 1145 #1146
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to put the starts_with calls into an array of files with certain prefixes
Could you please create a file makefile123 and run this PR, as shown in
your screenshots?
Because makefile123 startswith makefile the PR treats it as a makefile.
…On Mon, Feb 20, 2023, 17:40 tommady ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/info/filetype.rs
<#1146 (comment)>:
> @@ -22,9 +22,10 @@ impl FileExtensions {
#[allow(clippy::case_sensitive_file_extension_comparisons)]
fn is_immediate(&self, file: &File<'_>) -> bool {
file.name.to_lowercase().starts_with("readme") ||
+ file.name.to_lowercase().starts_with("makefile") ||
I just followed the GNU doc default description as I mentioned in the PR.
Other requests I think is beyond this PRs scope.
—
Reply to this email directly, view it on GitHub
<#1146 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACAYRE6CMEPYKBUEOBVXFODWYOM6TANCNFSM6AAAAAAS6HFP2A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
oh! I see what you meant ahah |
Your commit 92f8eba fixes what I meant. I have a question regarding performance. The function Line 502 in f3ca1fe
Line 501 in f3ca1fe
I am beginner of Rust, so reading the Standard library, The method
Is this the method used? "O(n)" means linear search. And for the sake of performance, sorting could be done by sorting the array in the source. What do you think? |
ya, I agree with your point. BTW, I am a rust beginner too~ |
@tommady, I appreciate the collaboration! I also think that is goes without saying, that any new filename needs to be added at its sorted positions.
|
On a second thought: As there could be other users, I would like to suggest to move the binary search into the function, together with a break-even calculation. Along the lines: So the potential other users would profit, too. Final argument: the |
Also, we must not I benchmarked
Break-even must be between 35 and 85, I will try to find it in the next days. |
Renaming the functions changes the benchmarked times!
|
wow and thank you for your survey which made me learn so much. |
I thought so 1 hour ago, but I realized that in the "real world" there are much more files which are not in the list. The number above come from a benchmark "1 file absent, 1 file present". So I changed the benchmark to: "4 files absent, 1 file present" and got:
This I understand, because As you see, this benchmark is in favor of In short: Could you please run and play with the benchmark? I don't know how trustworthy the measurements are. I just realize: for a directory (or tree listing) larger then 35, one would have to reverse the search and (binary) search 35 file names in the directory/listing. If you have a directory of 100 files, exa currently searches 100 times over a list of 35 entries. |
or just a stupid idea, we can make the immediate files into a static hashmap which will lead every search O(1). WDYT? |
Not stupid idea at all - I got the same. A hashmap is the fastest of the three methods, even if created within each benchmark function. So hashmap is the way forward.
The measurement supports the O(1) expectation. it is easy to setup a local, mutable hashmap. |
I saw the exa already uses the dependency "lazy_static", |
Unfortunately, PHF is slower than the dynamically created hashmap!
What am I doing wrong? |
or a more simple one? |
The first time, the lazy_static HashMap is as fast as the dynamically created one. Although, the second time there is no speed up. I'll try match
|
Match takes 0ns for 35 words, and 121ns for 85 words, double as for hash
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matches! macro increases readability.
Ya I think we should leave all those surveys for the maintainer to do the judgement. Clear winner for this PR (which the file names are below 35) is the matches macro with the fastest result with no doubts. |
Does it do a difference in term of final executable size? |
from this PR's modification, it added three strings
is this the reason? |
The issues with CI are not present in current master c697d06. I believe if you rebase your branch onto it the checks will pass. 1stDimension#3 I tried to create similar environment in my fork. |
Closing this, since exa is unmaintained (see #1243), and this has been merged in the active fork eza. Thanks! |
fix issue 1145
according to the GNU doc
results