mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-28 05:42:16 +08:00
Merge pull request #2161 from guill/compile_database_perf
Improve perf for compile dbs in large projects
This commit is contained in:
29
test/compile_database_perf/test.sh
Executable file
29
test/compile_database_perf/test.sh
Executable file
@@ -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"`
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user