Playing with Entity System, performance and D.
SrMordred via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jun 19 10:42:28 PDT 2017
I was playing around my ES and different ways of doing it with D.
I end up with a performance test of alias func vs ranges vs
opApply.
code here:
https://dpaste.dzfl.pl/a2eff240552f
Results on my machine win 10 x64, compiling with:
dub run --build=release --arch=x86 --compiler=ldc2
(unable to test with gdc because
https://forum.dlang.org/thread/bfmbvxtnqfhhgquayrro@forum.dlang.org)
Alias func: ~40ms
Range Type(front, popFront, emtpy): ~50ms
OpApply: ~25ms
So first, if I make some really dumb relate to profiling speed or
any D code let me know!
1) I thought that ranges were the fastest, but it got the least
performant code.
2) opApply was faster than alias func. Its suprising for me.
3) Not possible to return multiple values. So in the front()
method I Wrapped a node of pointers.(maybe a performance impact
here?, there is a better way of doing it? )
4) there are no equivalent of declaring Type& x; (ref type) right?
5) I saw sometimes people saying that oApply will be removed. But
i find it very powerfull (multiple returns for foreach is a must!
eg: foreach(x, y ; myrange) ), and on this case, faster than the
others.
PS: I know that the performance difference is minimal and may not
be noticeable on most(all) use cases, this is just for
fun/knowledge with profiling and to understand D behaviors :)
More information about the Digitalmars-d-learn
mailing list