summaryrefslogtreecommitdiff
path: root/xsd-examples/cxx/tree/performance/README
blob: 65e3edda565283efafd6ad20312e8c0615af2ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
This example measures the performance of parsing and serialization in
the C++/Tree mapping. It also shows how to structure your code to
achieve the maximum performance for these two operations.

The example consists of the following files:

test.xsd
  XML Schema which describes the test vocabulary.

test-50k.xml
  Test XML document.

gen.cxx
  Program to generate a test document of desired size.

  To compile and link this program we can use the following commands
  (replace 'c++' with your C++ compiler name):

  c++ -c gen.cxx
  c++ -o gen gen.o

  To generate the test document execute, for example:

  ./gen 633 test-100k.xml

time.hxx
time.cxx
  Class definition that represents time.

test.hxx
test.ixx
test.cxx
  C++ types that represent the given vocabulary, a set of parsing
  functions that convert XML documents to a tree-like in-memory object
  model, and a set of serialization functions that convert the object
  model back to XML.

  These files are generated by the XSD compiler from test.xsd using the
  following command line:

  xsd cxx-tree --generate-serialization test.xsd

parsing.cxx
  Parsing performance test. It first reads the entire document into
  a memory buffer. It then creates a DOM parser and pre-parses and
  caches the schema if validation is enabled. Finally, it runs the
  performance measurement loop which on each iteration parses the
  XML document from the in-memory buffer into DOM and then DOM to
  the object model.

serialization.cxx
  Serialization performance test. It first parses the XML document
  into the object model. It then creates a memory buffer into which
  the document is serialized and a DOM serializer. Finally, it runs
  the performance measurement loop which on each iteration serializes
  the object model to DOM and DOM to XML.

driver.cxx
  Driver for the example. It first parses the command line arguments.
  It then initializes the Xerces-C++ runtime and calls the parsing
  and serialization tests described above.

To compile and link the example manually from the command line we can use
the following commands (replace 'c++' with your C++ compiler name):

c++ -DXSD_CXX11 -c test.cxx
c++ -DXSD_CXX11 -c time.cxx
c++ -DXSD_CXX11 -c parsing.cxx
c++ -DXSD_CXX11 -c serialization.cxx
c++ -DXSD_CXX11 -c driver.cxx
c++ -o driver driver.o test.o time.o parsing.o serialization.o -lxerces-c

Note that we need to define the XSD_CXX11 preprocessor macro since the
source code includes libxsd headers directly.

To run the example on a test XML document execute:

./driver test-50k.xml

The -v option can be used to turn on validation in the underlying XML
parser (off by default). The -i option can be used to specify the
number of parsing and serialization iterations (1000 by default). For
example:

./driver -v -i 100 test-50k.xml