/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 validate/bench.java

  • Committer: Suren A. Chilingaryan
  • Date: 2009-09-23 17:13:04 UTC
  • Revision ID: csa@dside.dyndns.org-20090923171304-osvtr4zqb29h11kd
Intel, Tango, Phobos, and RapidXML parsers; Memory benchmark scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
import javax.xml.parsers.DocumentBuilder; 
6
6
 
7
7
public class bench {
8
 
    public void InitXML() {};
9
 
    public void InitXML_Validation() {};
 
8
    boolean large_data;
 
9
 
 
10
    public void InitXML(boolean large_data) {};
 
11
    public void InitXML_Validation(String schema_file) {};
10
12
    public void ReleaseXML() {};
11
13
    public void ParseXML(FileInputStream is, int iters, int iter) {};
12
14
    public void ValidateXML(FileInputStream is, int iters, int iter) {};
13
15
    
14
16
    public void Bench(String argv[]) throws IOException {
 
17
        String schema_file;
15
18
        int iterations,size,mode;
16
19
        
17
20
        if (argv.length<2) {
18
21
            System.err.println("Usage:\n\tme <iterations> <xml file|xmlgen|opcgen> [<xsd file>|size]");
19
22
        } else {
20
23
            iterations = Integer.parseInt(argv[0]);
 
24
            schema_file = argv[2];
21
25
 
22
26
            Collator mc = Collator.getInstance();
23
 
            if (mc.compare(argv[1],"xmlgen")==0) mode=1;
24
 
            else if (mc.compare(argv[1],"opcgen")==0) mode=2;
25
 
            else mode=0;
 
27
            if (mc.compare(argv[1],"xmlgen")==0) {
 
28
                mode=1;
 
29
                schema_file = "../xml.files/generated.xsd";
 
30
            } else if (mc.compare(argv[1],"opcgen")==0) {
 
31
                mode=2;
 
32
                schema_file = "../xml.files/opc.xsd";
 
33
            } else mode=0;
26
34
 
27
35
            if (mode>0) size = Integer.parseInt(argv[2]);
28
36
            else size=0;
38
46
            ms=new SimpleDateFormat("SSS");
39
47
            FileInputStream file;
40
48
            
 
49
            long max_length = 0;
 
50
            
 
51
            if (mode==0) {
 
52
                File file1 = new File(argv[1]);
 
53
                max_length = file1.length();
 
54
            } else {
 
55
                for (int i=0;i<=iterations;i++) {
 
56
                    File file1 = new File("../xml.tmp/" + i + ".xml");
 
57
                    long length = file1.length();
 
58
                    if (length > max_length) max_length = length;
 
59
                }
 
60
            }
 
61
            
 
62
            if (max_length > 5242880) large_data = true;
 
63
            else large_data = false;
 
64
 
41
65
            pre=new Date();
42
 
            InitXML();
 
66
            InitXML(large_data);
43
67
            post=new Date();
44
68
            a=Double.valueOf(s.format(post)).doubleValue();
45
69
            b=Double.valueOf(s.format(pre)).doubleValue();
76
100
            d.disp_post();
77
101
 
78
102
            pre=new Date();
79
 
            InitXML_Validation();
 
103
            InitXML_Validation(schema_file);
80
104
            post=new Date();
81
105
            a=Double.valueOf(s.format(post)).doubleValue();
82
106
            b=Double.valueOf(s.format(pre)).doubleValue();