Open ja0nz opened 2 years ago
Thanks for this!
At first I couldn't see the benefit because on my org-fc-directories
(still containing thousands of files) the difference in runtime was so small.
Trying it on my whole home directory, fd
is much faster.
I think the greatest improvement is limiting the search to files actually containing flashcards.
With the -exec
flag of find
, we might be able to avoid the extra xargs
and I assume fd
has something similar.
The commands will need some work though, so their results are exactly the same. (For example, the current rg command also finds org archive files).
I'll try to rewrite them and then do some end-to-end indexer benchmarks.
After a lot of experimentation, these three commands seem to behave exactly the same regarding hidden files, hidden directories and upper/lower case '.org' extensions.
"find -L %s -name \".*\" -prune -o -name \"[^.]*.org\" -type f -exec grep -l --null \"^:FC_CREATED\" {} \\+"
"rg ^:FC_CREATED: -L -l --null -g '[^.]*.org' %s"
"fd --type f -s -e org -g '[^.]*.org' -L %s --exec-batch grep -l --null \"^:FC_CREATED:\" {}"
As expected, rg
is significantly faster than find
.
I have benchmarked these on my home directory and the subdirectory I use for org files:
What's odd here is that fd
is slower than find
in one of the cases.
-e org
is made redundant by the latter glob pattern
but it appears to reduce the runtime.
I think it's safe to assume that anyone who has installed fd
would be fine installing rg
as well,
so until we can find a fd
command that is faster than find
in all cases,
I'll only add rg
as an alternative.
resolves l3kn/org-fc#69