diff options
author | w0rp <w0rp@users.noreply.github.com> | 2019-01-08 09:29:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-08 09:29:07 +0000 |
commit | 1d7acad891daad502b6c8314c137b456f3df47ff (patch) | |
tree | bfdfcf04704bd8d9f2ea01fd37985a6aaecd7ec6 /test | |
parent | 0fcd5e79a9be71027df6d7e77034d530fa9bf959 (diff) | |
parent | cb0a5c7a36122a053c6c86cab145aa4c0336f5ba (diff) | |
download | ale-1d7acad891daad502b6c8314c137b456f3df47ff.zip |
Merge pull request #2161 from guill/compile_database_perf
Improve perf for compile dbs in large projects
Diffstat (limited to 'test')
-rwxr-xr-x | test/compile_database_perf/test.sh | 29 | ||||
-rw-r--r-- | test/test_c_flag_parsing.vader | 21 |
2 files changed, 47 insertions, 3 deletions
diff --git a/test/compile_database_perf/test.sh b/test/compile_database_perf/test.sh new file mode 100755 index 00000000..15a2b442 --- /dev/null +++ b/test/compile_database_perf/test.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Generate source files for ALE to read. They don't have to be very long, the delay is in reading compile_commands, not actually running tests +mkdir -p gen_src +for i in {1..400}; do echo "const char *GeneratedFunc${i}() { return \"Word ${i}\"; }" > gen_src/source${i}.cpp; done + +# Create the compile_commands database +echo "[ {" > compile_commands.json + +for i in {1..399}; do + { + echo "\"command\": \"clang++ -c $(pwd)/gen_src/source${i}.cpp -o $(pwd)/build/obj/Debug/source${i}.o -MF $(pwd)/build/obj/Debug/source${i}.d -MMD -MP\"," + echo "\"directory\": \"$(pwd)/build\"," + echo "\"file\": \"$(pwd)/gen_src/source${i}.cpp\"" + echo "}, {" + } >> compile_commands.json +done + +{ + echo "\"command\": \"clang++ -c $(pwd)/gen_src/source400.cpp -o $(pwd)/build/obj/Debug/source400.o -MF $(pwd)/build/obj/Debug/source400.d -MMD -MP\"," + echo "\"directory\": \"$(pwd)/build\"," + echo "\"file\": \"$(pwd)/gen_src/source400.cpp\"" + echo "} ]" +} >> compile_commands.json + +# Start up vim and switch back and forth between files -- at least one of the files must be near the bottom of compile_commands.json +time vim -c "for i in range(0,20) | edit gen_src/source10.cpp | edit gen_src/source400.cpp | endfor" \ + -c "noautocmd qa!" \ + `find . | grep "source..\.cpp"` 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 |