Re: howto count lines - fast

2017-05-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 31, 2017 at 10:05:50PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Thursday, June 01, 2017 04:52:40 Patrick Schluter via Digitalmars-d-learn [...] > > See my link above to realdworldtech. Using SIMD can give good > > results in micro-benchmarks but completely screw up

Re: howto count lines - fast

2017-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, June 01, 2017 04:52:40 Patrick Schluter via Digitalmars-d-learn wrote: > On Thursday, 1 June 2017 at 04:39:17 UTC, Jonathan M Davis wrote: > > On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > Digitalmars-d-learn wrote: > >>

Re: howto count lines - fast

2017-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 1 June 2017 at 04:39:17 UTC, Jonathan M Davis wrote: On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via Digitalmars-d-learn wrote: [...] Digitalmars-d-learn wrote: [...] If you're really trying to make it fast, there may be something that you can do with SIMD. IIRC, Brian

Re: howto count lines - fast

2017-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 23:03:54 UTC, H. S. Teoh wrote: On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn wrote: > I did some digging around, and it seems that wc is using >

Re: howto count lines - fast

2017-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn > > > > wrote: > > > I did some digging around, and

Re: Rosetta Commatizing numbers

2017-05-31 Thread Solomon E via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 15:44:51 UTC, Ivan Kazmenko wrote: On Wednesday, 31 May 2017 at 13:27:24 UTC, Solomon E wrote: Fine, by the numbers: 1. pi has the commas start at the wrong digit, and doesn't follow the explicit instructions to use spaces as the separator and a grouping of 5

Re: Rosetta Commatizing numbers

2017-05-31 Thread Mike B Johnson via Digitalmars-d-learn
If you still insist you are doing the right thing and all others are wrong, let's agree to disagree on that, and please just leave the original solution there by introducing two versions. Or we could just agree that the original was wrong and needs fixing? That is obviously the right thing

Re: howto count lines - fast

2017-05-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jun 01, 2017 at 12:20:53AM +0100, Russel Winder via Digitalmars-d-learn wrote: [...] > However, I note here that the Chapel folk are taking a quite > interesting view of algorithm implementation in the Benchmarks Game. > They are totally eschewing "heroic implementations" such as all the

Re: howto count lines - fast

2017-05-31 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2017-05-30 at 17:22 -0700, H. S. Teoh via Digitalmars-d-learn wrote: > […] > performance in a significant way.  But I thought this might be a > useful > tip for people who want to squeeze out the last drop of juice from > their > CPUs. ;-) > […] I have the beginnings of wc written in

Re: howto count lines - fast

2017-05-31 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn > wrote: > > I did some digging around, and it seems that wc is using glibc's > > memchr, which is highly-optimized, whereas

Re: howto count lines - fast

2017-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn wrote: > I did some digging around, and it seems that wc is using glibc's memchr, > which is highly-optimized, whereas std.algorithm.count just uses a > simplistic loop. Which is strange, because I'm pretty sure somebody >

Re: Changing Template Static Ifs to Recursion

2017-05-31 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 19:22:18 UTC, Stefan Koch wrote: You could also use string mixins. Which will be more efficient then recursion. I try to avoid string mixins unless I can't help it. Nevertheless, I made an effort to try to get it to work and below seems to be working. I still

Re: howto count lines - fast

2017-05-31 Thread Nitram via Digitalmars-d-learn
I am glad to see this participation on this issue :) The hints about trying another compiler and std.mmfile turned out to be very effective. Even this simple code is faster then my systems "wc -l" now: void main() { import std.stdio; writeln(lcs("benchmark.dat")); } size_t

Re: howto count lines - fast

2017-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 23:41:01 UTC, H. S. Teoh wrote: On Tue, May 30, 2017 at 08:02:38PM +, Nitram via Digitalmars-d-learn wrote: After reading https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D. size_t

Re: Changing Template Static Ifs to Recursion

2017-05-31 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 19:25:22 UTC, ag0aep6g wrote: On 05/31/2017 08:50 PM, jmh530 wrote: Note: I left out the function foo, but think of foo is to Foo as tuple is to Tuple. You should have included foo, in my opinion. I'm having trouble figuring out what your code does. `process`

Re: Changing Template Static Ifs to Recursion

2017-05-31 Thread ag0aep6g via Digitalmars-d-learn
On 05/31/2017 08:50 PM, jmh530 wrote: Note: I left out the function foo, but think of foo is to Foo as tuple is to Tuple. You should have included foo, in my opinion. I'm having trouble figuring out what your code does. `process` instantiates foo with the field names. I'd need the definition

Re: Changing Template Static Ifs to Recursion

2017-05-31 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 18:50:27 UTC, jmh530 wrote: I have a struct that I am using like a Tuple, but I want to be able to opIndex in a different way than Tuple's opIndex. I want to be able to opIndex whatever is underlying the Tuple. [...] You could also use string mixins. Which will

Re: howto count lines - fast

2017-05-31 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, May 30, 2017 at 05:13:46PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > I could not make the D program come close to wc's performance when the > data was piped from stdin. [...] Hmm. This is a particularly interesting case, because I adapted some of my algorithms to handle

Changing Template Static Ifs to Recursion

2017-05-31 Thread jmh530 via Digitalmars-d-learn
I have a struct that I am using like a Tuple, but I want to be able to opIndex in a different way than Tuple's opIndex. I want to be able to opIndex whatever is underlying the Tuple. The code below works, but is kind of annoying because to extend you have to keep adding static ifs. I want to

Re: howto count lines - fast

2017-05-31 Thread cym13 via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 17:23:46 UTC, Ali Çehreli wrote: On 05/30/2017 11:50 PM, Daniel Kozak via Digitalmars-d-learn wrote: > How do you compile it? When I use ldc2 -O3 -release -mcpu=bdver1 lc.d > my code is even faster than wc My bad: I'm not familiar with ldc's optimization options.

Re: howto count lines - fast

2017-05-31 Thread Ali Çehreli via Digitalmars-d-learn
On 05/30/2017 11:50 PM, Daniel Kozak via Digitalmars-d-learn wrote: > How do you compile it? When I use ldc2 -O3 -release -mcpu=bdver1 lc.d > my code is even faster than wc My bad: I'm not familiar with ldc's optimization options. (I used -O3 but not -release) Now I get the same performance

Re: Question on @nothrow

2017-05-31 Thread Ali Çehreli via Digitalmars-d-learn
On 05/31/2017 02:10 AM, Vasileios Anagnostopoulos wrote: > compiler enforced @throws For that to be possible, the compiler would have to see all definitions, which is not possible with separate compilation. Besides, I think the only meaning of @throws would be "may throw". If so, since the

Re: Rosetta Commatizing numbers

2017-05-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 13:27:24 UTC, Solomon E wrote: Fine, by the numbers: 1. pi has the commas start at the wrong digit, and doesn't follow the explicit instructions to use spaces as the separator and a grouping of 5 Can be solved by calling the function with a right set of

Re: iOS Apps in D

2017-05-31 Thread solidstate1991 via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 12:49:38 UTC, Oleksii wrote: Hi everybody, Perhaps this topic has been raised many times before, but I'm going to go back to it anyways :-P Are there any good reference materials and/or tutorials on programming for iOS and Android in D? I wonder if anybody could

Re: Rosetta Commatizing numbers

2017-05-31 Thread Solomon E via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 04:31:14 UTC, Ivan Kazmenko wrote: On Tuesday, 30 May 2017 at 10:54:49 UTC, Solomon E wrote: I ran into a Rosetta code solution in D that had obvious errors. It's like the author or the previous editor wasn't even trying to do it right, like a protest against how

iOS Apps in D

2017-05-31 Thread Oleksii via Digitalmars-d-learn
Hi everybody, Perhaps this topic has been raised many times before, but I'm going to go back to it anyways :-P Are there any good reference materials and/or tutorials on programming for iOS and Android in D? I wonder if anybody could share their story of success with D on mobile? Thanks,

Re: Question on @nothrow

2017-05-31 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 09:31:48 UTC, Jonathan M Davis wrote: [...] Thank you for the answers.

Re: Question on @nothrow

2017-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 31, 2017 08:18:07 Vasileios Anagnostopoulos via Digitalmars-d-learn wrote: > Hi, > > after reading various articles bout the "supposed" drawbacks of > checked exceptions I started to have questions on @nothrow. Why > there exists and not a @throws annotation enforced by the >

Re: Question on @nothrow

2017-05-31 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 08:52:51 UTC, Mike Parker wrote: This has come up several times over the years. For summary, go to the search bar and type: "checked exceptions" Walter Do you realize that I do not talk about checked exceptions, only a compiler enforced @throws and nothing

Re: Question on @nothrow

2017-05-31 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 08:18:07 UTC, Vasileios Anagnostopoulos wrote: Hi, after reading various articles bout the "supposed" drawbacks of checked exceptions I started to have questions on @nothrow. Why there exists and not a @throws annotation enforced by the compiler? I understand

Question on @nothrow

2017-05-31 Thread Vasileios Anagnostopoulos via Digitalmars-d-learn
Hi, after reading various articles bout the "supposed" drawbacks of checked exceptions I started to have questions on @nothrow. Why there exists and not a @throws annotation enforced by the compiler? I understand that people are divided on checked exceptions and each side has some valid

Re: howto count lines - fast

2017-05-31 Thread Daniel Kozak via Digitalmars-d-learn
Dne 31.5.2017 v 02:13 Ali Çehreli via Digitalmars-d-learn napsal(a): I could not make the D program come close to wc's performance when the data was piped from stdin. A typical run with Daniel Kozak's program: $ time cat deleteme.txt | wc -l 5062176 real0m0.086s user0m0.068s sys