Re: passing a variadic parameter to randomSample

2022-01-26 Thread Stanislav Blinov via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 22:07:43 UTC, Ali Çehreli wrote: On 1/25/22 13:55, forkit wrote: > auto RandomChoice(R...)(R r) Watch out though: The compiler will compile a different function per set of values. For example, there will be separate RandomChoice instances for ("hello") vs. ("wor

Re: gdc or ldc for faster programs?

2022-01-26 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 04:28:25 UTC, Ali Çehreli wrote: On 1/25/22 16:15, Johan wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: >> >> I am using compilers installed by Manjaro Linux's package system: >> >> ldc: LDC - the LLVM D compiler (1.28.0): >> based on D

Re: gdc or ldc for faster programs?

2022-01-26 Thread forkit via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: Whenever I've watched talks/demos where benchmarks were the central topic, GDC has always blown LDC out the water when it comes to matters of math. .. https://dlang.org/blog/2020/05/14/lomutos-comeback/

Re: gdc or ldc for faster programs?

2022-01-26 Thread Johan via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: On Wednesday, 26 January 2022 at 04:28:25 UTC, Ali Çehreli wrote: On 1/25/22 16:15, Johan wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: >> >> I am using compilers installed by Manjaro Linux's package sys

Re: gdc or ldc for faster programs?

2022-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 1/26/22 04:06, Johan wrote: > The stdlib makes a huge difference in performance. > Ali's program uses string manipulation, Yes, on the surface, I thought my inner loop had just / and % but of course there is that formattedWrite. I will change the code to use sprintf into a static buffer (in

Re: passing a variadic parameter to randomSample

2022-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 1/26/22 02:20, Stanislav Blinov wrote: > On Tuesday, 25 January 2022 at 22:07:43 UTC, Ali Çehreli wrote: >> On 1/25/22 13:55, forkit wrote: >> >> > auto RandomChoice(R...)(R r) >> >> Watch out though: The compiler will compile a different function per >> set of values. For example, there will b

Re: gdc or ldc for faster programs?

2022-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/22 7:06 AM, Johan wrote: Couldn't test with LDC 1.6 (dlang2.076), because it is too old and not running on M1/Monterey (?). There was a range of macos dmd binaries that did not work after a certain MacOS. I think it had to do with the hack for TLS that apple changed, so it no longer

Re: passing a variadic parameter to randomSample

2022-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 1/26/22 07:44, Ali Çehreli wrote: > the instantiations could be too many for R... I am still wrong there. It is inconceivable to instantiate the following template for the same type (e.g. string) from "too many" places in a program: auto RandomChoice(R...)(R r) { // ... } There may be

Re: gdc or ldc for faster programs?

2022-01-26 Thread Ali Çehreli via Digitalmars-d-learn
ldc shines with sprintf. And dmd suprises by being a little bit faster than gdc! (?) ldc (2.098.0): ~6.2 seconds dmd (2.098.1): ~7.4 seconds gdc (2.076.?): ~7.5 seconds Again, here are the versions of the compilers that are readily available on my system: > ldc: LDC - the LLVM D compiler (1.

Re: gdc or ldc for faster programs?

2022-01-26 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:43:39 UTC, forkit wrote: On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: Whenever I've watched talks/demos where benchmarks were the central topic, GDC has always blown LDC out the water when it comes to matters of math. .. https://dlan

Re: gdc or ldc for faster programs?

2022-01-26 Thread Siarhei Siamashka via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:00:41 UTC, Ali Çehreli wrote: ldc shines with sprintf. And dmd suprises by being a little bit faster than gdc! (?) ldc (2.098.0): ~6.2 seconds dmd (2.098.1): ~7.4 seconds gdc (2.076.?): ~7.5 seconds Again, here are the versions of the compilers that are read

Re: gdc or ldc for faster programs?

2022-01-26 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:39:07 UTC, Siarhei Siamashka wrote: It's not DMD doing a good job here, but GDC11 shooting itself in the foot by requiring additional esoteric command line options if you really want to produce optimized binaries. The D language shot itself in the foot by

Re: gdc or ldc for faster programs?

2022-01-26 Thread Siarhei Siamashka via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 18:41:51 UTC, Iain Buclaw wrote: The D language shot itself in the foot by requiring templates to have weak semantics. If DMD and LDC inline weak functions, that's their bug. As I already mentioned in the bugzilla, it would be really useful to see a practical

Template sequence parameter and default value

2022-01-26 Thread Andrey Zherikov via Digitalmars-d-learn
What is the best way to emulate a default value for template sequence parameter of a function? I want something like this: ```d void foo(MODULES... = __MODULE__)() {} // these should work: foo!(module1, module2); foo!(module1); foo(); // this should use current module (__MODULE__) acc

Re: Template sequence parameter and default value

2022-01-26 Thread Jaime via Digitalmars-d-learn
On Thursday, 27 January 2022 at 02:49:22 UTC, Andrey Zherikov wrote: What is the best way to emulate a default value for template sequence parameter of a function? I want something like this: ```d void foo(MODULES... = __MODULE__)() {} // these should work: foo!(module1, module2); foo!(module1