req.addFilter(instancesFilter);
StringWriter xmlOut = new StringWriter();
StringWriter soapOut = new StringWriter();
new XMLMarshaller(new InvocationContext(Repository.getMetadata()), Repository.getMetadata())
.serialize(req, xmlOut);
new SOAPMarshaller(new InvocationContext(Repository.getMetadata())).serialize(req, soapOut);
System.err.println("XML vs. SOAP Unmarshaller Profiling Comparison");
// --- XML test
SOAPUnmarshaller unmarshaller =
new XMLUnmarshaller(new InvocationContext(Repository.getMetadata()),
Repository.getMetadata());
for (int i = 0; i < nWarmup; ++i)
{
unmarshaller.deserialize(new StringReader(xmlOut.toString()));
}
long lStartTime = System.currentTimeMillis();
for (int i = 0; i < nIterations; ++i)
{
unmarshaller.deserialize(new StringReader(xmlOut.toString()));
}
long lEndTime = System.currentTimeMillis();
long nSizeXML = xmlOut.toString().length();
long nTotalTimeXML = lEndTime - lStartTime;
System.err.println("Run: " + nIterations + " iterations in: " + nTotalTimeXML/(double)1000 +
" sec");
System.err.println("XML Time: " + nTotalTimeXML/(double)nIterations + " ms");
System.err.println("XML Size: " + nSizeXML + " chars");
System.err.println("XML Unit: " + nTotalTimeXML/(double)nIterations/nSizeXML * 1000000 +
" ns/char");
//--- SOAP test
unmarshaller = new SOAPUnmarshaller(new InvocationContext(Repository.getMetadata()));
for (int i = 0; i < nWarmup; ++i)
{
unmarshaller.deserialize(new StringReader(soapOut.toString()));
}