Re: Which option is faster...

2013-08-06 Thread Andre Artus
It's a long story and I will return in a few months and give you the whole story, but right now, time is not on my side. I have answers for all the questions you folks have asked, and I appreciate all the input. I have the answer that I was looking for, so in a few months, I will come back and

Re: Which option is faster...

2013-08-06 Thread dennis luehring
Am 07.08.2013 06:30, schrieb jicman: Again, what are you trying to achieve? Your statement is not necessarily true, for a myriad of reasons, but it entirely depends on what you want to do. I would reiterate Dennis Luehring's reply, why are you not benching? It seems like you are guessing at what

Re: Which option is faster...

2013-08-06 Thread jicman
On Tuesday, 6 August 2013 at 14:49:42 UTC, Andre Artus wrote: On Tuesday, 6 August 2013 at 12:32:13 UTC, jicman wrote: On Tuesday, 6 August 2013 at 04:10:57 UTC, Andre Artus wrote: On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.

Re: Which option is faster...

2013-08-06 Thread Andre Artus
On Tuesday, 6 August 2013 at 12:32:13 UTC, jicman wrote: On Tuesday, 6 August 2013 at 04:10:57 UTC, Andre Artus wrote: On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0

Re: Which option is faster...

2013-08-06 Thread H. S. Teoh
On Tue, Aug 06, 2013 at 02:32:11PM +0200, jicman wrote: > On Tuesday, 6 August 2013 at 04:10:57 UTC, Andre Artus wrote: [...] > >What exactly are you trying to do with this? I get the impression > >that there is an attempt at "local optimization" when broader > >approach could lead to better result

Re: Which option is faster...

2013-08-06 Thread Andrej Mitrovic
On 8/5/13, H. S. Teoh wrote: > If you really want optimal performance, use std.regex: Yes and if you also want to bloat your executable to the point that other parts of the system start slowing down.

Re: Which option is faster...

2013-08-06 Thread jicman
On Tuesday, 6 August 2013 at 04:10:57 UTC, Andre Artus wrote: On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls"

Re: Which option is faster...

2013-08-05 Thread Jonathan M Davis
On Monday, August 05, 2013 15:59:23 jicman wrote: > Greetings! > > I have this code, > > foreach (...) > { > >if (std.string.tolower(fext[0]) == "doc" || > std.string.tolower(fext[0]) == "docx" || > std.string.tolower(fext[0]) == "xls" || > std.string.tolower(fext[0]) == "xlsx

Re: Which option is faster...

2013-08-05 Thread dennis luehring
Am 05.08.2013 19:04, schrieb jicman: so its totaly unclear if the presented code is your 2h monster, what was the runtime of your jscript? The files are in a network drive, so, that has some slowness already involved because of that. The jscript use to take over 8 hours. The new D program has

Re: Which option is faster...

2013-08-05 Thread Andre Artus
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.stri

Re: Which option is faster...

2013-08-05 Thread Raphaël Jakse
Le 05/08/2013 15:59, jicman a écrit : Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.string.tolower(fe

Re: Which option is faster...

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 07:30:36PM +0200, JS wrote: > On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: > > > >Greetings! > > > >I have this code, > > > >foreach (...) > >{ > > > > if (std.string.tolower(fext[0]) == "doc" || > >std.string.tolower(fext[0]) == "docx" || > >std.string.t

Re: Which option is faster...

2013-08-05 Thread JS
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.stri

Re: Which option is faster...

2013-08-05 Thread Ali Çehreli
On 08/05/2013 10:04 AM, jicman wrote: > The files are in a network drive, so, that has some slowness already > involved because of that. Which may dominate the running time. > The jscript use to take over 8 hours. The new D program has > dropped that to under less than six. And that is proof

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 17:04:36 UTC, monarch_dodra wrote: On Monday, 5 August 2013 at 15:18:42 UTC, John Colvin wrote: better: foreach (...) { auto tmp = std.string.tolower(fext[0]); if(tmp == "doc" || tmp == "docx" || tmp == "xls" || tmp == "xlsx" || tmp == "ppt" || tmp

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 15:27:09 UTC, dennis luehring wrote: Am 05.08.2013 17:18, schrieb jicman: > It is a tool that was a script, but I have turned it into do, which now has taken two hours from the last jscript script. I have not benchmarked it, yet. I may. But I see that a great idea

Re: Which option is faster...

2013-08-05 Thread monarch_dodra
On Monday, 5 August 2013 at 15:18:42 UTC, John Colvin wrote: better: foreach (...) { auto tmp = std.string.tolower(fext[0]); if(tmp == "doc" || tmp == "docx" || tmp == "xls" || tmp == "xlsx" || tmp == "ppt" || tmp == "pptx") { continue; } } but still not s

Re: Which option is faster...

2013-08-05 Thread John Colvin
On Monday, 5 August 2013 at 15:21:25 UTC, David wrote: Am 05.08.2013 15:59, schrieb jicman: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolow

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 15:18:42 UTC, John Colvin wrote: On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" |

Re: Which option is faster...

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 04:47:36PM +0200, dennis luehring wrote: > > Ok, how would you make it faster? > > i don't see a better solution here - how to reduce ONE lowercase and > SOME compares in any way? (i dont think a hash or something will > help) but i know that anything like your continue-par

Re: Which option is faster...

2013-08-05 Thread dennis luehring
Am 05.08.2013 17:18, schrieb jicman: > It is a tool that was a script, but I have turned it into do, which now has taken two hours from the last jscript script. I have not benchmarked it, yet. I may. But I see that a great idea has been provided, which I will use. Thanks for the help. > hav

Re: Which option is faster...

2013-08-05 Thread David
Am 05.08.2013 15:59, schrieb jicman: > > Greetings! > > I have this code, > > foreach (...) > { > > if (std.string.tolower(fext[0]) == "doc" || > std.string.tolower(fext[0]) == "docx" || > std.string.tolower(fext[0]) == "xls" || > std.string.tolower(fext[0]) == "xlsx" || > std

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:50:27 UTC, bearophile wrote: jicman: How would you make it faster in D1? Compute std.string.tolower(fext[0]) and put it in a temporary variable. And then compare that variable with all your string literals. In most cases that's fast enough. If it's not enough,

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:47:37 UTC, dennis luehring wrote: > Ok, how would you make it faster? i don't see a better solution here - how to reduce ONE lowercase and SOME compares in any way? (i dont think a hash or something will help) but i know that anything like your continue-party is

Re: Which option is faster...

2013-08-05 Thread John Colvin
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.stri

Re: Which option is faster...

2013-08-05 Thread bearophile
jicman: How would you make it faster in D1? Compute std.string.tolower(fext[0]) and put it in a temporary variable. And then compare that variable with all your string literals. In most cases that's fast enough. If it's not enough, you could create a little finite state machine that represe

Re: Which option is faster...

2013-08-05 Thread dennis luehring
> Ok, how would you make it faster? i don't see a better solution here - how to reduce ONE lowercase and SOME compares in any way? (i dont think a hash or something will help) but i know that anything like your continue-party is worth nothing (feels a little bit like script-kiddies "do it with

Re: Which option is faster...

2013-08-05 Thread H. S. Teoh
On Mon, Aug 05, 2013 at 03:59:23PM +0200, jicman wrote: > > Greetings! > > I have this code, > > foreach (...) > { > > if (std.string.tolower(fext[0]) == "doc" || > std.string.tolower(fext[0]) == "docx" || > std.string.tolower(fext[0]) == "xls" || > std.string.tolower(fext[0]) ==

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:27:43 UTC, dennis luehring wrote: did you benchmarked your current szenario - how do you know that this is the slow part - or are you working on an only-extension-compare-tool? btw: they are both equal and slow - and full of partly code-duplication std.string.to

Re: Which option is faster...

2013-08-05 Thread dennis luehring
did you benchmarked your current szenario - how do you know that this is the slow part - or are you working on an only-extension-compare-tool? btw: they are both equal and slow - and full of partly code-duplication std.string.tolower(fext[0]) multiple times, i hope your list isn't going much lo

Re: Which option is faster...

2013-08-05 Thread Timon Gehr
On 08/05/2013 03:59 PM, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xlsx" || std.string.tolower(fe

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 14:13:33 UTC, Timon Gehr wrote: On 08/05/2013 03:59 PM, jicman wrote: Greetings! I have this code, foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string

Re: Which option is faster...

2013-08-05 Thread jicman
On Monday, 5 August 2013 at 13:59:24 UTC, jicman wrote: Greetings! I have this code, First option... foreach (...) { if (std.string.tolower(fext[0]) == "doc" || std.string.tolower(fext[0]) == "docx" || std.string.tolower(fext[0]) == "xls" || std.string.tolower(fext[0]) == "xl