|
| 1 | +FAQ |
| 2 | +=== |
| 3 | + |
| 4 | + |
| 5 | +Performance |
| 6 | +----------- |
| 7 | + |
| 8 | +pygccxml is being regularly optimised for performance, but it still may be slow |
| 9 | +in certain cases. |
| 10 | + |
| 11 | +Before all, it is highly recommended to benchmark your application if performance |
| 12 | +is important to you. There are multiple tools out there for benchmarking python |
| 13 | +applications. We currently are using the following two command lines / tools: |
| 14 | + |
| 15 | + | python -m cProfile -o profile_data.pyprof script_to_profile.py |
| 16 | + | pyprof2calltree -i profile_data.pyprof -k |
| 17 | +
|
| 18 | +Of course optimising pygccxml alone will not help in all cases. The bottlenecks can also be |
| 19 | +in the code calling pygccxml, to make sure to benchmark the whole process. |
| 20 | +Any help on the performance side is also welcome. |
| 21 | + |
| 22 | +Some things you may try (in order of priority): |
| 23 | + |
| 24 | +1) You might want to consider making the declaration tree as small as possible |
| 25 | + and only store those declarations that somehow have an influence on the bindings. |
| 26 | + Ideally, this is done as early as possible and luckily castxml and gccxml |
| 27 | + provide an option that allows you to reduce the number of declarations that |
| 28 | + need to be parsed. |
| 29 | + |
| 30 | + You can specify one or more declarations using the ``-fxml-start`` (gccxml) or |
| 31 | + ``-castxml-start`` (castxml) options when running the xml generator. For |
| 32 | + example, if you specify the name of a particular class, only this class |
| 33 | + and all its members will get written. Ideally, your project should already use |
| 34 | + a dedicated namespace, which you can then use as a starting point. |
| 35 | + All declarations stemming from system headers will be ignored (except |
| 36 | + for those declarations that are actually used within your library). |
| 37 | + |
| 38 | + In the pygccxml package you can set the value for these flags by using |
| 39 | + the ``start_with_declarations`` attribute of the ``pygccxml.parser.config_t`` |
| 40 | + object that you are passing to the parser. |
| 41 | + |
| 42 | +2) You can pass the following flag to the *read_files* method: |
| 43 | + |
| 44 | + compilation_mode=pygccxml.parser.COMPILATION_MODE.ALL_AT_ONCE |
| 45 | + |
| 46 | +3) If you want to cache the declarations tree, there is a caching mechanism provided |
| 47 | + by pygccxml. You will find an example of this mechanism in the examples section. |
0 commit comments