/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/tools.h

  • Committer: Suren A. Chilingaryan
  • Date: 2009-10-01 15:56:11 UTC
  • Revision ID: csa@dside.dyndns.org-20091001155611-9g3f1yad2w195t4g
Implement DOM walking mode for parsing benchmark in fast parsers

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#include "../xmlgen/xmark.h"
14
14
#endif /* GENERATOR_XMARK */
15
15
 
 
16
#define MAX_LEVELS 127
 
17
 
 
18
int walk_tree = 0;
 
19
int fast_mode = 0;
 
20
const char *walk_xpath = "//*[(@* or text()) and (count(../child::*)>3)]";
 
21
 
 
22
int get_walk_mode() {
 
23
    return walk_tree;
 
24
}
 
25
 
16
26
struct TestData {
17
27
    unsigned long iterations;
18
28
    unsigned long size;
22
32
    unsigned long xmllen;
23
33
};
24
34
 
25
 
char *ReadFile(char *fn) {
 
35
char *ReadFile(const char *fn) {
26
36
    FILE *f;
27
37
    struct stat st;
28
38
    char *buf;
79
89
    exit(0);
80
90
}
81
91
 
 
92
double get_value(const char *str) {
 
93
    double res;
 
94
    char *tmp;
 
95
 
 
96
    res = strtod(str,&tmp);
 
97
    if (*tmp) return 0;
 
98
    return res;
 
99
}
 
100
 
 
101
double get_value_0(const char *str, size_t len) {
 
102
    char copy[32];
 
103
    double res;
 
104
    char *tmp;
 
105
    
 
106
        // Too long to be a number
 
107
    if (len > 32) return 0;
 
108
    strncpy(copy, str, len); copy[len]=0;
 
109
    
 
110
    res = strtod(copy,&tmp);
 
111
    if (*tmp) return 0;
 
112
    return res;
 
113
}
 
114
 
82
115
int Test(int argc, char *argv[]) {
83
116
    int i,j;
84
117
    struct timeval pre_time,post_time;
93
126
    int execute_xml = 1;
94
127
    
95
128
    if (getenv("skip_xml")) execute_xml = 0;
 
129
    if (getenv("walk_tree")) walk_tree = 1;
 
130
    else walk_tree = 0;
 
131
    if (getenv("fast_mode")) fast_mode = 1;
 
132
    else fast_mode = 0;
 
133
 
96
134
    
97
135
    if ((argc<3)||(argc>4)) Usage(argv[0]);
98
136