Prev: Combobox Showing Right Justified
Next: Can't make exe
From: Mike Williams on 23 Mar 2010 17:55 "Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message news:O%239ulvsyKHA.5360(a)TK2MSFTNGP06.phx.gbl... > I timed 3 methods. One using a regex to normalize whitespace, > one to use basically the original version posted by mike with a > do loop/replace, and one using [the imposter's] stringbuilder as > a buffer to build a new string. As you are almost certainly aware, the "Replace in a loop" method I posted was for convenience and not for speed, since speed was not declared as an issue as far as the OP is concerned and he was more interested in any method that would perform the job for him. If I wanted a fast method of performing the OP's sepcific task in VB6 then I certainly would not use Replace in a loop, and would probably point a VB Integer array at the existing string data, which would be much faster. Mike
From: Tom Shelton on 23 Mar 2010 18:34 On 2010-03-23, Mike Williams <Mike(a)WhiskyAndCoke.com> wrote: > "Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message > news:O%239ulvsyKHA.5360(a)TK2MSFTNGP06.phx.gbl... > >> I timed 3 methods. One using a regex to normalize whitespace, >> one to use basically the original version posted by mike with a >> do loop/replace, and one using [the imposter's] stringbuilder as >> a buffer to build a new string. > > As you are almost certainly aware, the "Replace in a loop" method I posted > was for convenience and not for speed, since speed was not declared as an > issue as far as the OP is concerned and he was more interested in any method > that would perform the job for him. If I wanted a fast method of performing > the OP's sepcific task in VB6 then I certainly would not use Replace in a > loop, and would probably point a VB Integer array at the existing string > data, which would be much faster. I certainly am aware - in fact, I would probably do the same thing you describe if I were doing this in VB6. Fun with array discriptors :) But, Cor took issue with my offhand remark that I would probably use a regular expression in this case (only in .net, not in vb6). I do it that way, because I've always found it fast enough - and never felt the need to optimize it. He made a comment about he would use the replace/loop becasue replace was something like 50 times faster then a regex... It sounded bogus to me, so I timed it (and it was bogus)- and while I was at it made a StringBuilder version. I'm sure this will be of no interest to you as it was VB.NET. -- Tom Shelton
From: Mike Williams on 23 Mar 2010 19:27 "Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message news:%236ElGktyKHA.244(a)TK2MSFTNGP06.phx.gbl... > But, Cor took issue with my offhand remark . . . He made a comment > about he would use the replace/loop becasue replace was something > like 50 times faster then a regex... It sounded bogus to me, so I timed > it (and it was bogus) He probably didn't perform his tests properly. Sounds par for the course for him. I've never used Reg Expressions myself but I've just tried them in a VB6 project (using the VB6 Project / References to set a reference to Microsoft VBScript Regular Expressions) and one of the first things I noticed is that the setting of properties such as Pattern, IgnoreCase etc are massively slower, at least an order of magnitude slower, the first time you use them than they are on the second and subsequent times, so in most cases it would be far better to hang onto one after you have initialised it. Mike
From: Bob O`Bob on 23 Mar 2010 19:30 Cor Ligthert[MVP] wrote: > It was meant as VB6 answer, but I had to do it from my head, like I > wrote, I've VB6 not here. Who do we report **SPAM** like this to? Is it still MVPGA? PJ Forgione? Bob EX-MVP for VB --
From: Tom Shelton on 23 Mar 2010 20:00
On 2010-03-23, Mike Williams <Mike(a)WhiskyAndCoke.com> wrote: > "Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message > news:%236ElGktyKHA.244(a)TK2MSFTNGP06.phx.gbl... > >> But, Cor took issue with my offhand remark . . . He made a comment >> about he would use the replace/loop becasue replace was something >> like 50 times faster then a regex... It sounded bogus to me, so I timed >> it (and it was bogus) > > He probably didn't perform his tests properly. Sounds par for the course for > him. I've never used Reg Expressions myself but I've just tried them in a > VB6 project (using the VB6 Project / References to set a reference to > Microsoft VBScript Regular Expressions) and one of the first things I > noticed is that the setting of properties such as Pattern, IgnoreCase etc > are massively slower, at least an order of magnitude slower, the first time > you use them than they are on the second and subsequent times, so in most > cases it would be far better to hang onto one after you have initialised it. Interesting... I never used RegEx much in VB.CLASSIC - because I didn't want to reference the scripting runtime. My guess is they would be 50 times slower in that case :) -- Tom Shelton |