/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/libxml.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-10-09 04:07:13 UTC
  • Revision ID: csa@dside.dyndns.org-20091009040713-mel06whc852tf2xz
XPath expression optimizations, various fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//#define USE_XPATH
2
1
#include <stdio.h>
3
2
#include <sys/time.h>
4
3
#include <libxml/xmlmemory.h>
5
4
#include <libxml/parser.h>
6
 
#ifdef USE_XPATH
7
 
# include <libxml/xpath.h>
8
 
#endif
 
5
#include <libxml/xpath.h>
9
6
 
10
7
#if LIBXML_VERSION > 20600
11
8
#define READ_MEMORY
44
41
    return 0;
45
42
}
46
43
 
47
 
#ifdef USE_XPATH
48
44
inline double xpath_walker(xmlNodeSetPtr nodes) {
49
45
    int i;
50
46
    double res = 0;
56
52
    
57
53
    return res;
58
54
}
59
 
#else
 
55
 
60
56
double walker(xmlNode *node) {
61
57
    int i = 0;
62
58
    double res = 0;
80
76
    }
81
77
    return res;
82
78
}
83
 
#endif
84
79
 
85
80
 
86
81
void initXML(struct TestData *td) {
125
120
 
126
121
    if (walk_tree) {
127
122
        double res;
128
 
#ifdef USE_XPATH
129
 
        xmlXPathContextPtr xpathCtx; 
130
 
        xmlXPathObjectPtr xpathObj; 
131
 
 
132
 
        xpathCtx = xmlXPathNewContext(doc);
133
 
        xpathObj = xmlXPathEvalExpression(walk_xpath, xpathCtx);
134
 
        if (xpathObj) {
135
 
            res = xpath_walker(xpathObj->nodesetval);
136
 
            xmlXPathFreeObject(xpathObj);
137
 
            xmlXPathFreeContext(xpathCtx); 
 
123
 
 
124
        if (force_xpath) {
 
125
            xmlXPathContextPtr xpathCtx; 
 
126
            xmlXPathObjectPtr xpathObj; 
 
127
 
 
128
            xpathCtx = xmlXPathNewContext(doc);
 
129
            xpathObj = xmlXPathEvalExpression(walk_xpath, xpathCtx);
 
130
            if (xpathObj) {
 
131
                res = xpath_walker(xpathObj->nodesetval);
 
132
                xmlXPathFreeObject(xpathObj);
 
133
                xmlXPathFreeContext(xpathCtx); 
 
134
            }
 
135
        } else {
 
136
            res = walker(xmlDocGetRootElement(doc));
138
137
        }
139
 
#else
140
 
        res = walker(xmlDocGetRootElement(doc));
141
 
#endif
142
138
//      printf("Sum: %lf\n", res);
143
139
    }
144
140