benchmark stuff
Co-authored-by: Ne_Eo <NeeEoo@users.noreply.github.com>
This commit is contained in:
+2
-2
@@ -27,8 +27,8 @@
|
||||
|
||||
|
||||
# Copying the assets from source code to bin folder
|
||||
--cmd rm -rf bin/cpp/assets
|
||||
--cmd cp -r assets bin/cpp/assets
|
||||
# --cmd rm -rf bin/cpp/assets
|
||||
# --cmd cp -r assets bin/cpp/assets
|
||||
--cpp bin/cpp
|
||||
--cmd cd bin/cpp
|
||||
--cmd ./Main
|
||||
+30
-2
@@ -10,9 +10,37 @@ class Main {
|
||||
static function main() {
|
||||
#if BENCHMARK
|
||||
Sys.println("Running benchmark");
|
||||
|
||||
|
||||
//new Benchmark("Test", 1000);
|
||||
new TestBenchmark();
|
||||
var haxeTotalTime:Float = 0;
|
||||
var hscriptTotalTime:Float = 0;
|
||||
|
||||
var haxeTimes:Array<Float> = [];
|
||||
var hscriptTimes:Array<Float> = [];
|
||||
|
||||
var iterations:Int = 10;
|
||||
for (i in 0...iterations) {
|
||||
var benchmark:TestBenchmark = new TestBenchmark();
|
||||
|
||||
haxeTimes.push(benchmark.haxeTotalTime);
|
||||
hscriptTimes.push(benchmark.hscriptTotalTime);
|
||||
|
||||
haxeTotalTime += benchmark.haxeTotalTime;
|
||||
hscriptTotalTime += benchmark.hscriptTotalTime;
|
||||
}
|
||||
|
||||
haxeTimes.sort((a, b) -> return a > b ? 1 : -1);
|
||||
hscriptTimes.sort((a, b) -> return a > b ? 1 : -1);
|
||||
|
||||
var slowestHaxeTime:Float = haxeTimes[haxeTimes.length-1];
|
||||
var slowestHscriptTime:Float = hscriptTimes[hscriptTimes.length-1];
|
||||
var fastestHaxeTime:Float = haxeTimes[0];
|
||||
var fastestHscriptTime:Float = hscriptTimes[0];
|
||||
|
||||
var haxeWon = hscriptTotalTime > haxeTotalTime;
|
||||
Sys.println('${haxeWon ? "Haxe" : "Hscript"} was faster overall (Faster by: ${Util.roundWith((haxeWon ? hscriptTotalTime/haxeTotalTime : haxeTotalTime/hscriptTotalTime), 100)}x)');
|
||||
Sys.println('Haxe average time: ${Util.convertToReadableTime(haxeTotalTime/iterations)} (Highest: ${Util.convertToReadableTime(slowestHaxeTime)}) (Lowest: ${Util.convertToReadableTime(fastestHaxeTime)})');
|
||||
Sys.println('Hscript average time: ${Util.convertToReadableTime(hscriptTotalTime/iterations)} (Highest: ${Util.convertToReadableTime(slowestHscriptTime)}) (Lowest: ${Util.convertToReadableTime(fastestHscriptTime)})');
|
||||
#else
|
||||
Sys.println("Beginning tests");
|
||||
if(!Main.SHOW_KNOWN_BUGS) {
|
||||
|
||||
@@ -11,7 +11,10 @@ class Benchmark extends HScriptRunner {
|
||||
|
||||
public function new(name:String, iterations:Int) {
|
||||
super();
|
||||
doBenchmark(name, iterations);
|
||||
}
|
||||
|
||||
public function doBenchmark(name:String, iterations:Int) {
|
||||
haxeTimes = cast new haxe.ds.Vector<Float>(iterations);
|
||||
hscriptTimes = cast new haxe.ds.Vector<Float>(iterations);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user