/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 create/mono-dom.cs

  • Committer: Suren A. Chilingaryan
  • Date: 2009-09-29 02:14:05 UTC
  • Revision ID: csa@dside.dyndns.org-20090929021405-378i2zuuiudt77m1
DOM Creation benchmark for mono and tango

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.IO;
 
3
using System.Xml;
 
4
 
 
5
using XMLBench;
 
6
 
 
7
namespace XMLBench {
 
8
 public class MonoBench : XMLBench {
 
9
    string nsxsi="http://www.w3.org/2001/XMLSchema-instance";
 
10
    string nsenc="http://www.w3.org/2001/12/soap-encoding";
 
11
    string nssoap="http://www.w3.org/2001/12/soap-envelope";
 
12
    string nsopc="http://opcfoundation.org/webservices/OPCDA/";
 
13
 
 
14
    override public void ParseXML(int enlarge, int iters, int iter) {
 
15
        XmlDocument doc = new XmlDocument();
 
16
 
 
17
        XmlElement proot,pnode,node,node1,node2;
 
18
        StringWriter mem = new StringWriter();
 
19
        int i;
 
20
 
 
21
        doc = new XmlDocument();
 
22
        proot = doc.CreateElement("Envelope",nssoap);
 
23
        proot.SetAttribute("xmlns",nssoap);
 
24
        proot.SetAttribute("xmlns:xsi",nsxsi);
 
25
        proot.SetAttribute("xmlns:enc",nsenc);
 
26
        doc.AppendChild(proot);
 
27
        pnode = doc.CreateElement("Body",nssoap);
 
28
        proot.AppendChild(pnode);
 
29
 
 
30
        node=doc.CreateElement("WriteResponse",nsopc);
 
31
        pnode.AppendChild(node);
 
32
        pnode=node;
 
33
        node=doc.CreateElement("WriteResult",nsopc);
 
34
        node.SetAttribute("RcvTime","2002-04-29T10:16:26.6806250+02:00");
 
35
        node.SetAttribute("ReplyTime","2002-04-29T10:16:26.7806250+02:00");
 
36
        node.SetAttribute("ClientRequestHandle","WriteError");
 
37
        node.SetAttribute("RevisedLocaleID","en");
 
38
        node.SetAttribute("ServerState","running");
 
39
        pnode.AppendChild(node);
 
40
        node1=doc.CreateElement("RItemList",nsopc);
 
41
        pnode.AppendChild(node1);
 
42
        node=doc.CreateElement("Errors",nsopc);
 
43
        node.SetAttribute("ID","E_UNKNOWNITEMID");
 
44
        pnode.AppendChild(node);
 
45
        node2=doc.CreateElement("Text",nsopc);
 
46
        node.AppendChild(node2);
 
47
        node2.AppendChild(doc.CreateTextNode("The item does not exist in the server address space."));
 
48
        node=doc.CreateElement("Errors",nsopc);
 
49
        node.SetAttribute("ID","S_CLAMP");
 
50
        pnode.AppendChild(node);
 
51
        node2=doc.CreateElement("Text",nsopc);
 
52
        node.AppendChild(node2);
 
53
        node2.AppendChild(doc.CreateTextNode("The value written was accepted but the output was clamped."));
 
54
 
 
55
        pnode=node1;
 
56
        node=doc.CreateElement("Items",nsopc);
 
57
        node.SetAttribute("ItemPath","");
 
58
        node.SetAttribute("ItemName","WrongItemID1");
 
59
        node.SetAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
60
        node.SetAttribute("ErrorID","E_UNKNOWNITEMID");
 
61
        pnode.AppendChild(node);
 
62
        node1=doc.CreateElement("Value",nsopc);
 
63
        node.AppendChild(node1);
 
64
        node.SetAttribute("xsi:nil","true");
 
65
 
 
66
        node=doc.CreateElement("Items",nsopc);
 
67
        node.SetAttribute("ItemPath","");
 
68
        node.SetAttribute("ItemName","WrongItemID2");
 
69
        node.SetAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
70
        node.SetAttribute("ErrorID","E_UNKNOWNITEMID");
 
71
        pnode.AppendChild(node);
 
72
        node1=doc.CreateElement("Value",nsopc);
 
73
        node.AppendChild(node1);
 
74
        node.SetAttribute("xsi:nil","true");
 
75
 
 
76
        node=doc.CreateElement("Items",nsopc);
 
77
        node.SetAttribute("ItemPath","/Reals");
 
78
        node.SetAttribute("ItemName","Float1");
 
79
        node.SetAttribute("ValueType","xsd:float");
 
80
        node.SetAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
81
        pnode.AppendChild(node);
 
82
        node1=doc.CreateElement("Value",nsopc);
 
83
        node.AppendChild(node1);
 
84
        node.SetAttribute("xsi:type","xsd:float");
 
85
        node1.AppendChild(doc.CreateTextNode("10.0141414"));
 
86
 
 
87
        node=doc.CreateElement("Items",nsopc);
 
88
        node.SetAttribute("ItemPath","/Reals");
 
89
        node.SetAttribute("ItemName","Float2");
 
90
        node.SetAttribute("ValueType","xsd:float");
 
91
        node.SetAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
92
        node.SetAttribute("SuccessID","S_CLAMP");
 
93
        pnode.AppendChild(node);
 
94
        node1=doc.CreateElement("Value",nsopc);
 
95
        node.AppendChild(node1);
 
96
        node.SetAttribute("xsi:type","xsd:float");
 
97
        node1.AppendChild(doc.CreateTextNode("1.07"));
 
98
 
 
99
        for (i=0;i<enlarge;i++) {
 
100
            node=doc.CreateElement("Items",nsopc);
 
101
            node.SetAttribute("ItemPath","/Integer");
 
102
            node.SetAttribute("ItemName","IntN");
 
103
            node.SetAttribute("ValueType","xsd:int");
 
104
            node.SetAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
105
            node.SetAttribute("SuccessID","S_CLAMP");
 
106
            pnode.AppendChild(node);
 
107
            node1=doc.CreateElement("Value",nsopc);
 
108
            node.AppendChild(node1);
 
109
            node.SetAttribute("xsi:type","xsd:int");
 
110
            node1.AppendChild(doc.CreateTextNode(""+generator.Next()));
 
111
        }
 
112
        XmlTextWriter w = new XmlTextWriter(mem);
 
113
        doc.WriteTo(w);
 
114
 
 
115
        if (iter==iters) Console.WriteLine(mem);
 
116
    }
 
117
 }
 
118
 
 
119
 public class Mono {
 
120
    public static void Main(string[] args) {
 
121
        XMLBench bench = new MonoBench();
 
122
        bench.Bench(args);
 
123
    }
 
124
 }
 
125
}