Methods Summary |
---|
private static void | dumpXml(org.xmlpull.v1.XmlPullParser parser)
int eventType = parser.nextTag();
while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG:
parser.getName();
// System.out.print("<" + parser.getName());
int nattrs = parser.getAttributeCount();
for (int i = 0; i < nattrs; ++i) {
parser.getAttributeName(i);
parser.getAttributeValue(i);
// System.out.print(" " + parser.getAttributeName(i) + "=\""
// + parser.getAttributeValue(i) + "\"");
}
// System.out.print(">");
break;
case XmlPullParser.END_TAG:
parser.getName();
// System.out.print("</" + parser.getName() + ">");
break;
case XmlPullParser.TEXT:
parser.getText();
// System.out.print(parser.getText());
break;
default:
// do nothing
}
eventType = parser.next();
}
|
private byte[] | getBytesForResource(int resid)
// all resources are written into a zip file, so the InputStream we
// get for a resource is on top of zipped
// data. in order to compare performance of parsing unzipped vs.
// zipped content, we first read the data into an in-memory buffer.
InputStream zipIs = null;
try {
zipIs = mContext.getResources().openRawResource(resid);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
int bytesRead = zipIs.read(buf);
while (bytesRead > 0) {
baos.write(buf, 0, bytesRead);
bytesRead = zipIs.read(buf);
}
return baos.toByteArray();
} finally {
if (zipIs != null) {
zipIs.close();
}
}
|
public boolean | isPerformanceOnly()
return true;
|
private static void | parseXml(java.io.InputStream is)
XmlPullParser xmlParser = Xml.newPullParser();
XmlGDataParser parser = new XmlGDataParser(is, xmlParser);
Feed feed = parser.init();
Entry entry = null;
while (parser.hasMoreData()) {
entry = parser.readNextEntry(entry);
}
|
private static void | parseXml(org.xmlpull.v1.XmlPullParser xmlP)
XmlGDataParser parser = new XmlGDataParser(null /* in */, xmlP);
Feed feed = parser.init();
Entry entry = null;
while (parser.hasMoreData()) {
entry = parser.readNextEntry(entry);
}
|
public int | startPerformance(PerformanceTestCase.Intermediates intermediates)
return 0;
|
public void | testBinaryXml()
XmlResourceParser parser = mContext.getResources().getXml(R.xml.calendar);
parseXml(parser);
parser.close();
|
public void | testJson()
String jsonString = new String(getBytesForResource(R.raw.calendarjs), "UTF-8");
JSONTokener tokens = new JSONTokener(jsonString);
assertNotNull(new JSONObject(tokens));
|
public void | testXml()
InputStream is = new ByteArrayInputStream(getBytesForResource(R.raw.calendarxml));
try {
is.reset();
parseXml(is);
} finally {
is.close();
}
|
public void | testXmlGzip()
InputStream gzIs = new GZIPInputStream(
new ByteArrayInputStream(getBytesForResource(R.raw.calendarxmlgz)));
try {
parseXml(gzIs);
} finally {
gzIs.close();
}
|