Skip to content

Commit 1e42f6c

Browse files
committed
Add a FAQ with a section about performance (#56)
1 parent 53f5068 commit 1e42f6c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

docs/faq.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Documentation contents
5252
install
5353
examples
5454
documentation
55+
faq
5556
query_interface
5657
design
5758
users

0 commit comments

Comments
 (0)