Hi Juraj, thanks for your example.
I applied your test on my own case, check it out:
http://try.haxe.org/#2389DThe first one tests the Abstract Enum which I intended to use in the first place.
The second one tests the Enum without the inlined abstract aspect.
And the third one tests the argument as being Dynamic
Here are my result in FF:
13:29:26:396 Test.hx:6: 1.561999797821045s
13:29:27:849 Test.hx:14: 1.4519999027252197s
13:29:27:868 Test.hx:22: 0.018000125885009766s
The first test with the inlined abstract element is slightly slower then the second one without the inlined abstract element. So your right about the fact that the difference is very small as a result of using extra assignments. The difference is very small but yet unnecessary. It’s also a matter of principal, why loosing speed on assignments that are not necessary? Also it increases the file in size and other non-haxe programmers are not gonna dig the extra load.
As in for pretty output code, I’m not asking for a work of art :P Just code that is optimised as much as possible. Where you guys already did a great job doing so due to macros, absrtacts, and the inline element :D :D :D
The third test is yet a whole other story, the Dynamic test is immensely faster than the tests with the Enums. I didn’t espect the difference between the Enum and Dynamic would be so big. The downside of course is that it is not typed according to the Haxe philosophy.
Concerning this I was wondering if it's possible to use an Enum in Haxe for having it typed but then outputing Dynamic for a better performance?
Maybe a little miscommunication but I don’t use chaining for a better performance. I hope it does... but my main reason is for readability, and more pleasant coding. Consider this code:
Without chaining:
var a = new A();
a.doThis();
a.doThat();
var b = new B();
b.doWhatever();
b.useThis( a );
trace( b.toString() );
With chaining:
trace(
new B()
.doWhatever()
.useThis(
new A()
.doThis()
.doThat()
)
.toString()
);
You see, it’s leaner, easier to read and coding wise more pleasant if you ask me. In this small example the difference is not really big but when the case scenario gets bigger, chaining really improves in readability, overview and so on.
Adrian
Op dinsdag 30 juni 2015 11:34:31 UTC+2 schreef back2dos: