HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.14k stars 655 forks source link

[cpp] [hl] Slow performance of trace command #8830

Open sebthom opened 5 years ago

sebthom commented 5 years ago

The following code runs significantly slower on HL and CPP compared to other targets:

class TraceTest {

    public static function main() {
        var start = haxe.Timer.stamp();
        for (i in 1...2000)
            trace(i);
        var duration =  Math.round((haxe.Timer.stamp() - start)*100) / 100;
        trace('Duration: $duration seconds.');
    }
}

I tested Haxe 4RC5 on Windows 10, these are my results:

Target Duration
CPP 18.73 secs
HL 1.10 10.5 secs
PHP5 0.88 secs
Java8 0.85 secs
Node.js 10.16 0.65 secs
C# 0.51secs
PHP7 0.51 secs
Neko2.2 0.49 secs
Python3.7 0.45 secs
Aurel300 commented 5 years ago

Might have something to do with flushing stdout maybe?

ncannasse commented 5 years ago

Yes, HL will flush stdout on every print, maybe we could only do that when debugger is enabled

sebthom commented 2 years ago

Yes, HL will flush stdout on every print, maybe we could only do that when debugger is enabled

@ncannasse The issue is still present in Haxe 4.2.5 and HL 1.1.2. Do you think you could implement your suggestion?