summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2018-07-10 18:41:19 +0100
committerNeil Fuller <nfuller@google.com>2018-07-11 14:02:00 +0100
commitf4634736ca409ad0391992b93d9b82623eff9301 (patch)
treeb3447aaa293b803b477eee99346f2318c421bab0 /sax
parent7980b19bc8fa1fb0c4b4b3abea891d6e245b3edd (diff)
downloadbase-f4634736ca409ad0391992b93d9b82623eff9301.tar.gz
Move XML object factory logic to libcore
It makes sense to hide the details of the parser implementation (and other similar objects) in libcore so it could be changed. This change removes the "ExpatPerformanceTest" which appears not to have been maintained and was comparing KxmlParser with itself. It is assumed that android.util.Xml used to return the expat parser. Test: build Bug: 111055375 Merged-In: Ibad247323ba90cd949aecb2bd92f2f73306a4327 Change-Id: Ibad247323ba90cd949aecb2bd92f2f73306a4327
Diffstat (limited to 'sax')
-rw-r--r--sax/tests/saxtests/src/android/sax/ExpatPerformanceTest.java125
1 files changed, 0 insertions, 125 deletions
diff --git a/sax/tests/saxtests/src/android/sax/ExpatPerformanceTest.java b/sax/tests/saxtests/src/android/sax/ExpatPerformanceTest.java
deleted file mode 100644
index 892c49052533..000000000000
--- a/sax/tests/saxtests/src/android/sax/ExpatPerformanceTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.sax;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.util.Xml;
-import org.kxml2.io.KXmlParser;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.android.frameworks.saxtests.R;
-
-public class ExpatPerformanceTest extends AndroidTestCase {
-
- private static final String TAG = ExpatPerformanceTest.class.getSimpleName();
-
- private byte[] mXmlBytes;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- InputStream in = mContext.getResources().openRawResource(R.raw.youtube);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int length;
- while ((length = in.read(buffer)) != -1) {
- out.write(buffer, 0, length);
- }
- mXmlBytes = out.toByteArray();
-
- Log.i("***", "File size: " + (mXmlBytes.length / 1024) + "k");
- }
-
- @LargeTest
- public void testPerformance() throws Exception {
-// try {
-// Debug.startMethodTracing("expat3");
-// for (int i = 0; i < 1; i++) {
- runJavaPullParser();
- runSax();
- runExpatPullParser();
-// }
-// } finally {
-// Debug.stopMethodTracing();
-// }
- }
-
- private InputStream newInputStream() {
- return new ByteArrayInputStream(mXmlBytes);
- }
-
- private void runSax() throws IOException, SAXException {
- long start = System.currentTimeMillis();
- Xml.parse(newInputStream(), Xml.Encoding.UTF_8, new DefaultHandler());
- long elapsed = System.currentTimeMillis() - start;
- Log.i(TAG, "expat SAX: " + elapsed + "ms");
- }
-
- private void runExpatPullParser() throws XmlPullParserException, IOException {
- long start = System.currentTimeMillis();
- XmlPullParser pullParser = Xml.newPullParser();
- pullParser.setInput(newInputStream(), "UTF-8");
- withPullParser(pullParser);
- long elapsed = System.currentTimeMillis() - start;
- Log.i(TAG, "expat pull: " + elapsed + "ms");
- }
-
- private void runJavaPullParser() throws XmlPullParserException, IOException {
- XmlPullParser pullParser;
- long start = System.currentTimeMillis();
- pullParser = new KXmlParser();
- pullParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
- pullParser.setInput(newInputStream(), "UTF-8");
- withPullParser(pullParser);
- long elapsed = System.currentTimeMillis() - start;
- Log.i(TAG, "java pull parser: " + elapsed + "ms");
- }
-
- private static void withPullParser(XmlPullParser pullParser)
- throws IOException, XmlPullParserException {
- int eventType = pullParser.next();
- while (eventType != XmlPullParser.END_DOCUMENT) {
- switch (eventType) {
- case XmlPullParser.START_TAG:
- pullParser.getName();
-// int nattrs = pullParser.getAttributeCount();
-// for (int i = 0; i < nattrs; ++i) {
-// pullParser.getAttributeName(i);
-// pullParser.getAttributeValue(i);
-// }
- break;
- case XmlPullParser.END_TAG:
- pullParser.getName();
- break;
- case XmlPullParser.TEXT:
- pullParser.getText();
- break;
- }
- eventType = pullParser.next();
- }
- }
-}