浏览代码

fix benchs for non-sys targets

Aleksandr Kuzmenko 6 年之前
父节点
当前提交
048ad50b34
共有 3 个文件被更改,包括 15 次插入2 次删除
  1. 1 0
      tests/benchs/.gitignore
  2. 2 0
      tests/benchs/src/Macro.hx
  3. 12 2
      tests/benchs/src/Main.hx

+ 1 - 0
tests/benchs/.gitignore

@@ -0,0 +1 @@
+bin

+ 2 - 0
tests/benchs/src/Macro.hx

@@ -1,9 +1,11 @@
+#if macro
 import haxe.macro.Context;
 import haxe.macro.Expr;
 import haxe.io.Path;
 
 using StringTools;
 using sys.FileSystem;
+#end
 
 class Macro {
 	static var singleCaseField = null;

+ 12 - 2
tests/benchs/src/Main.hx

@@ -6,12 +6,22 @@ class Main {
 		var cases = Macro.getCases("cases");
 		var printer = new ResultPrinter();
 		function print(result:SuiteResult) {
-			Sys.println(printer.print(result));
+			println(printer.print(result));
 		}
 
 		for (benchCase in cases) {
-			Sys.println('Case: ${benchCase.name}');
+			println('Case: ${benchCase.name}');
 			benchCase.exec.run(print);
 		}
 	}
+
+	static public inline function println(msg:String) {
+		#if sys
+		Sys.println(msg);
+		#elseif js
+		js.Syntax.code('console.log({0})', msg);
+		#else
+		trace(msg);
+		#end
+	}
 }