digitalmars.D.learn - Dude about ~ array concatenation performance
- ddcovery (37/37) Dec 01 2020 Yesterday I really shocked when, comparing one algorithm written
- ddcovery (2/6) Dec 01 2020 Sorry about title (may be "doubt" :-/ )
- Max Haughton (4/8) Dec 01 2020 Use ldc, rdmd can invoke it for you. DMD's optimizer is not even
- ddcovery (9/19) Dec 01 2020 Impressive performance increase:
- Max Haughton (3/23) Dec 01 2020 I've written a github issue on your repository with flags to get
- H. S. Teoh (10/19) Dec 01 2020 Yeah, when it comes to performance-related things, don't bother with
- ddcovery (4/23) Dec 02 2020 After applying adecuate parametrization (thanks to Max Haughton
Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! The idea is to translate the "3 lines sort" in haskell to Javascript and D (with the limitations of each language). This is not a quick sort test, but a "expressiveness" example of functional orientation: you "declare" that the sorted version of an array is, given one of it's elements, the sorted version of the smaller ones, plus the item, plus the sorted version of the greater ones. In javascript const sorted = ([pivot, ...others]) => pivot === void 0 ? [] : [ ...sorted(others.filter(v => v < pivot)), pivot, ...sorted(others.filter(v => v >= pivot)) ]; In D T[] sorted(T)(T[] values) { return values.length == 0 ? [] : sorted(values[1 .. $].filter!(v => v < values[0]).array()) ~ items[0 .. 1] ~ sorted(values[1 .. $].filter!(v => v >= values[0]).array()); } With 1 million Double numbers (generated randomly): Javascript (node 12): 1507 ms DMD: 2166 ms With 6 million Double numbers Javascript (node 12): 10776 ms DMD: 15243 ms You can find more detains in https://github.com/ddcovery/expressive_sort I will really appreciate some improvements... the only "rule" is that "sorted" must be written, preferably, as a single expression ("declarative" way, avoiding imperative instructions) and, of course, you can't use the native library "sort" methods :-) ).
Dec 01 2020
On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote:Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...]Sorry about title (may be "doubt" :-/ )
Dec 01 2020
On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote:Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...]Use ldc, rdmd can invoke it for you. DMD's optimizer is not even close to as advanced as a modern JavaScript engine's - that's why we use it for fast build times instead of performance.
Dec 01 2020
On Tuesday, 1 December 2020 at 23:43:31 UTC, Max Haughton wrote:On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote:Impressive performance increase: $ ldc2 -O -release --run sorted.d 1.0M: 810 ms 1.5M: 1324 ms 3.0M: 2783 ms 6.0M: 5727 ms Thanks MaxYesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...]Use ldc, rdmd can invoke it for you. DMD's optimizer is not even close to as advanced as a modern JavaScript engine's - that's why we use it for fast build times instead of performance.
Dec 01 2020
On Wednesday, 2 December 2020 at 00:08:55 UTC, ddcovery wrote:On Tuesday, 1 December 2020 at 23:43:31 UTC, Max Haughton wrote:I've written a github issue on your repository with flags to get the most out of LLVM.On Tuesday, 1 December 2020 at 22:49:55 UTC, ddcovery wrote:Impressive performance increase: $ ldc2 -O -release --run sorted.d 1.0M: 810 ms 1.5M: 1324 ms 3.0M: 2783 ms 6.0M: 5727 ms Thanks MaxYesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!! [...]Use ldc, rdmd can invoke it for you. DMD's optimizer is not even close to as advanced as a modern JavaScript engine's - that's why we use it for fast build times instead of performance.
Dec 01 2020
On Tue, Dec 01, 2020 at 10:49:55PM +0000, ddcovery via Digitalmars-d-learn wrote:Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!![...]With 1 million Double numbers (generated randomly): Javascript (node 12): 1507 ms DMD: 2166 ms With 6 million Double numbers Javascript (node 12): 10776 ms DMD: 15243 msYeah, when it comes to performance-related things, don't bother with DMD. Its optimizer is known to have limitations, and IME consistently produces code that underperforms LDC-generated code by about 20-30%, sometimes even as high as 40%. For performance comparisons, always use GDC/LDC. T -- If you're not part of the solution, you're part of the precipitate.
Dec 01 2020
On Wednesday, 2 December 2020 at 06:31:49 UTC, H. S. Teoh wrote:On Tue, Dec 01, 2020 at 10:49:55PM +0000, ddcovery via Digitalmars-d-learn wrote:After applying adecuate parametrization (thanks to Max Haughton for the tips), LDC generated code is running almost 3 times faster than DMD one!!!Yesterday I really shocked when, comparing one algorithm written in javascript and the equivalent in D, javascript performed better!!![...]With 1 million Double numbers (generated randomly): Javascript (node 12): 1507 ms DMD: 2166 ms With 6 million Double numbers Javascript (node 12): 10776 ms DMD: 15243 msYeah, when it comes to performance-related things, don't bother with DMD. Its optimizer is known to have limitations, and IME consistently produces code that underperforms LDC-generated code by about 20-30%, sometimes even as high as 40%. For performance comparisons, always use GDC/LDC. T
Dec 02 2020