-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #392 from angelozerr/memory-improvement
Improve memory with Integer (see #389)
- Loading branch information
Showing
11 changed files
with
191 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/performance/DOMParserPerformance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lsp4xml.performance; | ||
|
||
import static org.eclipse.lsp4xml.utils.IOUtils.convertStreamToString; | ||
|
||
import java.io.InputStream; | ||
|
||
import org.eclipse.lsp4xml.commons.TextDocument; | ||
import org.eclipse.lsp4xml.dom.DOMDocument; | ||
import org.eclipse.lsp4xml.dom.DOMParser; | ||
|
||
/** | ||
* This utility class is used to check the memory usage of {@link DOMParser}, | ||
* loading the large nasa.xml file. | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class DOMParserPerformance { | ||
|
||
public static void main(String[] args) { | ||
InputStream in = DOMParserPerformance.class.getResourceAsStream("/xml/nasa.xml"); | ||
String text = convertStreamToString(in); | ||
TextDocument document = new TextDocument(text, "nasa.xml"); | ||
// Continuously parses the large nasa.xml file with the DOM parser. | ||
while (true) { | ||
long start = System.currentTimeMillis(); | ||
DOMDocument xmlDocument = DOMParser.getInstance().parse(document, null); | ||
System.err.println("Parsed 'nasa.xml' with DOMParser in " + (System.currentTimeMillis() - start) + " ms."); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
org.eclipse.lsp4xml/src/test/java/org/eclipse/lsp4xml/performance/XMLScannerPerformance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Red Hat Inc. and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.lsp4xml.performance; | ||
|
||
import static org.eclipse.lsp4xml.utils.IOUtils.convertStreamToString; | ||
|
||
import java.io.InputStream; | ||
|
||
import org.eclipse.lsp4xml.dom.parser.Scanner; | ||
import org.eclipse.lsp4xml.dom.parser.TokenType; | ||
import org.eclipse.lsp4xml.dom.parser.XMLScanner; | ||
|
||
/** | ||
* This utility class is used to check the memory usage of {@link XMLScanner}, | ||
* loading the large nasa.xml file | ||
* | ||
* @author Angelo ZERR | ||
* | ||
*/ | ||
public class XMLScannerPerformance { | ||
|
||
public static void main(String[] args) { | ||
InputStream in = XMLScannerPerformance.class.getResourceAsStream("/xml/nasa.xml"); | ||
String text = convertStreamToString(in); | ||
// Continuously parses the large nasa.xml file with the XML scanner | ||
while (true) { | ||
long start = System.currentTimeMillis(); | ||
Scanner scanner = XMLScanner.createScanner(text); | ||
TokenType token = scanner.scan(); | ||
while (token != TokenType.EOS) { | ||
token = scanner.scan(); | ||
} | ||
System.err.println("Parsed 'nasa.xml' with XMLScanner in " + (System.currentTimeMillis() - start) + " ms."); | ||
} | ||
} | ||
} |
Oops, something went wrong.