dart test performance with aot compilation
This commit is contained in:
parent
c43965ff03
commit
7cb0d427d4
|
@ -22,10 +22,8 @@ import org.antlr.v4.runtime.misc.Interval;
|
|||
import org.antlr.v4.runtime.misc.Pair;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.semantics.SemanticPipeline;
|
||||
import org.antlr.v4.test.runtime.BaseRuntimeTest;
|
||||
import org.antlr.v4.test.runtime.ErrorQueue;
|
||||
import org.antlr.v4.test.runtime.RuntimeTestSupport;
|
||||
import org.antlr.v4.test.runtime.StreamVacuum;
|
||||
import org.antlr.v4.test.runtime.*;
|
||||
import org.antlr.v4.test.runtime.descriptors.PerformanceDescriptors;
|
||||
import org.antlr.v4.tool.*;
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.STGroup;
|
||||
|
@ -46,6 +44,8 @@ import static org.junit.Assert.assertArrayEquals;
|
|||
|
||||
|
||||
public class BaseDartTest implements RuntimeTestSupport {
|
||||
private static final List<String> AOT_COMPILE_TESTS = Collections.singletonList(new PerformanceDescriptors.DropLoopEntryBranchInLRRule_4().input);
|
||||
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
public static final String pathSep = System.getProperty("path.separator");
|
||||
|
||||
|
@ -380,7 +380,7 @@ public class BaseDartTest implements RuntimeTestSupport {
|
|||
assertTrue(success);
|
||||
writeFile(tmpdir, "input", input);
|
||||
writeLexerTestFile(lexerName, showDFA);
|
||||
String output = execClass("Test.dart");
|
||||
String output = execClass("Test", false);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -478,7 +478,8 @@ public class BaseDartTest implements RuntimeTestSupport {
|
|||
lexerName,
|
||||
startRuleName,
|
||||
showDiagnosticErrors,
|
||||
profile);
|
||||
profile,
|
||||
AOT_COMPILE_TESTS.contains(input));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -555,7 +556,8 @@ public class BaseDartTest implements RuntimeTestSupport {
|
|||
String lexerName,
|
||||
String parserStartRuleName,
|
||||
boolean debug,
|
||||
boolean profile) {
|
||||
boolean profile,
|
||||
boolean aotCompile) {
|
||||
this.stderrDuringParse = null;
|
||||
if (parserName == null) {
|
||||
writeLexerTestFile(lexerName, false);
|
||||
|
@ -567,19 +569,40 @@ public class BaseDartTest implements RuntimeTestSupport {
|
|||
profile);
|
||||
}
|
||||
|
||||
return execClass("Test.dart");
|
||||
return execClass("Test", true);
|
||||
}
|
||||
|
||||
public String execRecognizer() {
|
||||
return execClass("Test.dart");
|
||||
}
|
||||
|
||||
public String execClass(String className) {
|
||||
public String execClass(String className, boolean compile) {
|
||||
try {
|
||||
String[] args = new String[]{
|
||||
locateDart(),
|
||||
className, new File(tmpdir, "input").getAbsolutePath()
|
||||
};
|
||||
if (compile) {
|
||||
String[] args = new String[]{
|
||||
locateDart2Native(),
|
||||
className + ".dart", "-o", className
|
||||
};
|
||||
String cmdLine = Utils.join(args, " ");
|
||||
System.err.println("Compile: " + cmdLine);
|
||||
Process process =
|
||||
Runtime.getRuntime().exec(args, null, new File(tmpdir));
|
||||
StreamVacuum stderrVacuum = new StreamVacuum(process.getErrorStream());
|
||||
stderrVacuum.start();
|
||||
int result = process.waitFor();
|
||||
if (result != 0) {
|
||||
stderrVacuum.join();
|
||||
System.err.print("Error compiling dart file: " + stderrVacuum.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String[] args;
|
||||
if (compile) {
|
||||
args = new String[]{
|
||||
new File(tmpdir, className).getAbsolutePath(), new File(tmpdir, "input").getAbsolutePath()
|
||||
};
|
||||
} else {
|
||||
args = new String[]{
|
||||
locateDart(),
|
||||
className + ".dart", new File(tmpdir, "input").getAbsolutePath()
|
||||
};
|
||||
}
|
||||
String cmdLine = Utils.join(args, " ");
|
||||
System.err.println("execParser: " + cmdLine);
|
||||
Process process =
|
||||
|
@ -658,6 +681,23 @@ public class BaseDartTest implements RuntimeTestSupport {
|
|||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
protected String locateDart2Native() {
|
||||
String propName = getPropertyPrefix() + "-dart2native";
|
||||
String prop = System.getProperty(propName);
|
||||
|
||||
if (prop == null || prop.length() == 0) {
|
||||
prop = locateTool("dart2native");
|
||||
}
|
||||
|
||||
File file = new File(prop);
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new RuntimeException("Missing system property:" + propName);
|
||||
}
|
||||
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
private String locateRuntime() {
|
||||
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
final URL runtimeSrc = loader.getResource("Dart");
|
||||
|
@ -937,31 +977,6 @@ public class BaseDartTest implements RuntimeTestSupport {
|
|||
writeFile(tmpdir, "Test.dart", outputFileST.render());
|
||||
}
|
||||
|
||||
public void writeRecognizerAndCompile(String parserName, String lexerName,
|
||||
String parserStartRuleName,
|
||||
boolean debug,
|
||||
boolean profile) {
|
||||
if (parserName == null) {
|
||||
writeLexerTestFile(lexerName, debug);
|
||||
} else {
|
||||
writeTestFile(parserName,
|
||||
lexerName,
|
||||
parserStartRuleName,
|
||||
debug,
|
||||
profile);
|
||||
}
|
||||
}
|
||||
|
||||
protected void eraseFiles(final String filesEndingWith) {
|
||||
File tmpdirF = new File(tmpdir);
|
||||
String[] files = tmpdirF.list();
|
||||
for (int i = 0; files != null && i < files.length; i++) {
|
||||
if (files[i].endsWith(filesEndingWith)) {
|
||||
new File(tmpdir + "/" + files[i]).delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void eraseFiles() {
|
||||
if (tmpdir == null) {
|
||||
return;
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ParseTreesDescriptors {
|
|||
|
||||
@Override
|
||||
public boolean ignore(String targetName) {
|
||||
return !targetName.matches("Java|Python2|Python3|Node|Swift|CSharp");
|
||||
return !targetName.matches("Java|Python2|Python3|Node|Swift|CSharp|Dart");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -639,7 +639,7 @@ public class ParserErrorsDescriptors {
|
|||
|
||||
@Override
|
||||
public boolean ignore(String targetName) {
|
||||
return !"Java".equals(targetName) && !"Swift".equals(targetName);
|
||||
return !"Java".equals(targetName) && !"Swift".equals(targetName) && !"Dart".equals(targetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ public class PerformanceDescriptors {
|
|||
@Override
|
||||
public boolean ignore(String targetName) {
|
||||
// passes, but still too slow in Python and JavaScript
|
||||
return !Arrays.asList("Java", "CSharp", "Cpp", "Swift").contains(targetName);
|
||||
return !Arrays.asList("Java", "CSharp", "Cpp", "Swift", "Dart").contains(targetName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* can be found in the LICENSE.txt file in the project root.
|
||||
*/
|
||||
|
||||
import '../util/murmur_hash.dart';
|
||||
|
||||
class Pair<A, B> {
|
||||
final A a;
|
||||
final B b;
|
||||
|
@ -12,7 +14,7 @@ class Pair<A, B> {
|
|||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is Pair<A, B> && a == other.a && b == other.b;
|
||||
return identical(this, other) || other is Pair && a == other.a && b == other.b;
|
||||
}
|
||||
|
||||
String toString() {
|
||||
|
@ -21,6 +23,11 @@ class Pair<A, B> {
|
|||
|
||||
@override
|
||||
int get hashCode {
|
||||
return a.hashCode ^ b.hashCode;
|
||||
MurmurHash.initialize();
|
||||
|
||||
int hash = MurmurHash.initialize();
|
||||
hash = MurmurHash.update(hash, a);
|
||||
hash = MurmurHash.update(hash, b);
|
||||
return MurmurHash.finish(hash, 2);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue