diff options
author | Jacob Segal <jacob.e.segal@gmail.com> | 2018-12-16 20:47:35 -0800 |
---|---|---|
committer | Jacob Segal <jacob.e.segal@gmail.com> | 2019-01-06 00:41:57 -0800 |
commit | cb0a5c7a36122a053c6c86cab145aa4c0336f5ba (patch) | |
tree | fc61bb533d5f629e611fad30bb26d8806f2333cc /test/test_c_flag_parsing.vader | |
parent | 5bbe77101db18968fde65210956e54750d7ff4f5 (diff) | |
download | ale-cb0a5c7a36122a053c6c86cab145aa4c0336f5ba.zip |
Improve perf for compile dbs in large projects
When using a compilation database (compile_commands.json) in very large
projects, significant delays would occur when changing files --
particularly those that happened to be far down the db. Rather than
iterating over the whole list every time, we now build up a lookup table
based on the tail of the filename (and tail of the directory for
widening searches) and iterate over the much smaller list of compile
commands for files with the given name.
Test metrics (from compile_database_perf/test.sh) show a 90% performance
improvement -- from 25 seconds to 2.5 seconds per run.
Diffstat (limited to 'test/test_c_flag_parsing.vader')
-rw-r--r-- | test/test_c_flag_parsing.vader | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader index d3cb2b51..4c23c711 100644 --- a/test/test_c_flag_parsing.vader +++ b/test/test_c_flag_parsing.vader @@ -161,14 +161,14 @@ Execute(FlagsFromCompileCommands should tolerate empty values): AssertEqual '', ale#c#FlagsFromCompileCommands(bufnr(''), '') Execute(ParseCompileCommandsFlags should tolerate empty values): - AssertEqual '', ale#c#ParseCompileCommandsFlags(bufnr(''), '', []) + AssertEqual '', ale#c#ParseCompileCommandsFlags(bufnr(''), '', {}, {}) Execute(ParseCompileCommandsFlags should parse some basic flags): noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) AssertEqual \ '-I' . ale#path#Simplify('/usr/include/xmms2'), - \ ale#c#ParseCompileCommandsFlags(bufnr(''), ale#path#Simplify('/foo/bar/xmms2-mpris'), [ + \ ale#c#ParseCompileCommandsFlags(bufnr(''), ale#path#Simplify('/foo/bar/xmms2-mpris'), { "xmms2-mpris.c": [ \ { \ 'directory': ale#path#Simplify('/foo/bar/xmms2-mpris'), \ 'command': '/usr/bin/cc -I' . ale#path#Simplify('/usr/include/xmms2') @@ -176,7 +176,22 @@ Execute(ParseCompileCommandsFlags should parse some basic flags): \ . ' -c ' . ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c'), \ 'file': ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c'), \ }, - \ ]) + \ ] }, {}) + +Execute(ParseCompileCommandsFlags should fall back to files in the same directory): + noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) + + AssertEqual + \ '-I' . ale#path#Simplify('/usr/include/xmms2'), + \ ale#c#ParseCompileCommandsFlags(bufnr(''), ale#path#Simplify('/foo/bar/xmms2-mpris'), {}, { "src": [ + \ { + \ 'directory': ale#path#Simplify('/foo/bar/xmms2-mpris'), + \ 'command': '/usr/bin/cc -I' . ale#path#Simplify('/usr/include/xmms2') + \ . ' -o CMakeFiles/xmms2-mpris.dir/src/xmms2-mpris.c.o' + \ . ' -c ' . ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c'), + \ 'file': ale#path#Simplify((has('win32') ? 'C:' : '') . '/foo/bar/xmms2-mpris/src/xmms2-other.c'), + \ }, + \ ] }) Execute(ParseCFlags should not merge flags): AssertEqual |