aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorpipehat <pipehat@users.noreply.github.com>2020-05-07 08:41:57 +0200
committerGitHub <noreply@github.com>2020-05-07 09:41:57 +0300
commit81d49d3321b8e0460daa14fe0e2247ec90664806 (patch)
treed5d244074359d3373cbb9feed0edc2c25abf347a /test
parentfcd5de979a007d5d1840dfcf09fa1ca0d44db12d (diff)
Improve performance of native indexing (#1528)
Originally reported under bug #675, native indexing for non-trivial projects is extremely slow due to repeated invocations of (projectile-ignored-[files|directories]) during recursion. @shitikanth proposed a solution under #1495 in Feb 2020. This PR incorporates @bbatsov's feedback on #1495 and may resolve #1495 and close #675. Thanks to @shitikanth for initial research and solution idea. Benchmarking suggests at least a 10x improvement. e.g.: indexing the projectile source project itself under linux: (benchmark-run 3 (projectile-dir-files-native default-directory)) OLD: (2.109717349 25 0.5421294649999999) NEW: (0.098484531 1 0.022120505000000013) The effect was even more pronounced for me on Windows.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index c5cf90a..dbf99f6 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -1414,3 +1414,26 @@ You'd normally combine this with `projectile-test-with-sandbox'."
(describe "projectile-find-file-in-directory"
(it "fails when called in a non-existing directory"
(expect (projectile-find-file-in-directory "asdf") :to-throw)))
+
+(describe "projectile-dir-files-native"
+ (it "calculates ignored files and directories only once during recursion"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("projectA/"
+ "projectA/.svn/"
+ "projectA/src/.svn/"
+ "projectA/src/html/.svn/"
+ "projectA/.git/"
+ "projectA/src/html/"
+ "projectA/src/framework/lib/"
+ "projectA/src/framework.conf"
+ "projectA/src/html/index.html"
+ "projectA/.projectile")
+
+ ;; verify that indexing only invokes these funcs once during recursion
+ (spy-on 'projectile-ignored-files :and-call-through)
+ (spy-on 'projectile-ignored-directories :and-call-through)
+
+ (projectile-dir-files-native "projectA/")
+ (expect 'projectile-ignored-files :to-have-been-called-times 1)
+ (expect 'projectile-ignored-directories :to-have-been-called-times 1)))))