Benchmarking mir.ndslice + lubeck against numpy and Julia

bachmeier no at
Sun Jan 12 11:58:51 UTC 2020

On Sunday, 12 January 2020 at 10:25:09 UTC, p.shkadzko wrote:
> On Sunday, 12 January 2020 at 07:04:00 UTC, Ola Fosheim Grostad 
> wrote:
>> On Saturday, 11 January 2020 at 21:54:13 UTC, p.shkadzko wrote:
>>> Today I decided to write a couple of benchmarks to compare D 
>>> mir with lubeck against Python numpy, then I also added Julia 
>>> snippets. The results appeared to be quite interesting.
>> A decent optimizer would remove all your code except the print 
>> statement. Make sure to output the result of the computation. 
>> Also make sure you use the same algorithms and accuracy. If 
>> you write your own innerproduct in one language then you 
>> should do so in the other languages as well and require the 
>> result to follow ieee754 by evaluating the result.
>> Please note that floating point code cannot be fully 
>> restructured by the optimizer without setting the optimizer to 
>> less predictable fast-math settings. So it cannot even in 
>> theory approach hand tuned library code.
> Yes, it all should be there, I was impatient to share the 
> timings.
> On the other hand, I believe that stating that D can be faster 
> at something but you only have to know which compiler to use, 
> correct flags, maybe don't use dub because its defaults are bad 
> will never going to work.

These things can make *some* difference, but not the kind of 
difference you're claiming to have uncovered.

> Python out-of-the-box gives you such guarantees saying: "here 
> is a programming language for you that is easy as a toaster and 
> btw be assured that it will run fast no matter what stupid 
> thing you do".

If you're doing simple things, sure, Python will just forward 
your requests to underlying C/C++/Fortran libraries, but any 
language - including D - can do that. You could have achieved the 
same results using Ruby, Tcl, or Perl as you did with your Python 
code. As soon as you start doing something involved, where some 
parts of your code are pure Python and some parts are 
C/C++/Fortran, performance falls apart in a hurry.

More information about the Digitalmars-d mailing list