[cfe-dev] Clang indexing library performance

Tobias Grosser tobias at grosser.es
Sat Oct 1 16:34:04 PDT 2011


On 10/01/2011 10:34 AM, Alexander Bolodurin wrote:
> I was playing with libclang-based indexing and clang_complete plugin for Vim.
> Having found completion responsiveness a bit lacking, I decided to track down whether it's plugin's fault.
>
> To put the indexer under stress, I've made up an artificial test with the biggest and baddest C++ headers:
>
> ---------------8<---------------
> #include<boost/asio.hpp>
> #include<boost/regex.hpp>
> #include<boost/thread.hpp>
> #include<boost/spirit.hpp>
> #include<boost/signals2.hpp>
> boost::
> ---------------8<---------------
>
> ...and the following minimal test program using Python bindings:
>
> ---------------8<---------------
> from clang import cindex

        PrecompiledPreamble = 0x04
        CacheCompletionResults = 0x08
        CXXPrecompiledPreamble = 0x10
        flags = PrecompiledPreamble |
                CXXPrecompiledPreamble |
                CacheCompletionResults
  > def clock(f):
>      import time
>      def wrapf(*args,**kw):
>          start = time.time()
>          f(*args,**kw)
>          end = time.time()
>          print f.func_name, end - start
>      return wrapf



>
> fname='...path to file...'
> idx=cindex.Index.create()


> @clock
> def parse():
>      global tu
>      opts = ['-I/opt/local/include'] # MacPorts Boost path
>      tu=idx.parse(fname,opts)

        tu=idx.parse(fname,opts, [], flags)

This should give you a lot better results. You need to define these 
flags by yourself, as they are not yet available in the official python 
bindings.

> @clock
> def complete():
>      c = tu.codeComplete(fname,6,8)

Maybe using this may help even further:
        c = tu.codeComplete(fname,6,8, flags)

>
> parse()
> for i in range(4):
>      complete()
> ---------------8<---------------
>
> This is the timing I get on a Macbook Pro:
>
> parse 3.96061992645
> complete 3.31106615067
> complete 3.17438578606
> complete 3.37997102737
> complete 3.16793084145

Can you send me your new results, either only with the parse() change, 
and then with both the parse() and the complete() change.

Thanks and cheers
Tobi



More information about the cfe-dev mailing list