Skip to content

Commit

Permalink
Add XMLDocumentTest to test performance (see #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Sep 5, 2018
1 parent b0389c6 commit e092e44
Show file tree
Hide file tree
Showing 2 changed files with 15,198 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.eclipse.lsp4xml.internal.parser;

import java.io.InputStream;

import org.eclipse.lsp4xml.commons.TextDocument;
import org.eclipse.lsp4xml.model.XMLDocument;
import org.junit.Test;

public class XMLDocumentTest {

@Test
public void testLargeFile() {
InputStream in = XMLDocumentTest.class.getResourceAsStream("/xml/largeFile.xml");
String text = convertStreamToString(in);
TextDocument document = new TextDocument(text, "largeFile.xml");
long start = System.currentTimeMillis();
XMLDocument xmlDocument = XMLParser.getInstance().parse(document);
System.err.println("Parsed in " + (System.currentTimeMillis() - start) + " ms.");
}

static String convertStreamToString(InputStream is) {
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
}
Loading

0 comments on commit e092e44

Please sign in to comment.