Speed of horizontal flip

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 1 07:00:51 PDT 2015


tchaloupka:

> Am I doing something utterly wrong?

If you have to perform performance benchmarks then use ldc or gdc.

Also disable bound tests with your compilation switches.

Sometimes reverse() is not efficient, I think, it should be 
improved. Try to replace it with a little function written by you.

Add the usual pure/nothrow/@nogc/@safe annotations where you can 
(they don't increase speed much, usually).

And you refer to flip as "method", so if you are using classes 
don't forget to make the method final.

Profile the code and look for the performance bottlenecks.

You can even replace the *w multiplications with an increment of 
an index each loop, but this time saving is dwarfed by the 
reverse().

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list