Path: csiph.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.uzoreto.com!aioe.org!wIgm+2MIUUYkuZKIR0Uhug.user.gioia.aioe.org.POSTED!not-for-mail
From: "R.Wieser"
Newsgroups: microsoft.public.scripting.vbscript
Subject: Re: Why does a loop using instr() and mid() get slower on larger data ? - found it (I think)
Date: Sun, 3 Jan 2021 08:58:33 +0100
Organization: Aioe.org NNTP Server
Lines: 29
Message-ID:
References:
NNTP-Posting-Host: wIgm+2MIUUYkuZKIR0Uhug.user.gioia.aioe.org
X-Complaints-To: abuse@aioe.org
X-Priority: 3
X-RFC2646: Format=Flowed; Original
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
Xref: csiph.com microsoft.public.scripting.vbscript:12330
Mayayana,
> I don't know. InStr is incredibly fast. I suspect the
> wrapper bloat is much of the time.
Yesterday, ofcourse just after I called it a night and switched my 'puter
off, I got a brainfart. Just now I tested it.
You mentioned caseless searching, and that is what I have been doing (and
forgot to mention, sorry). Changing that last InStr argument back to
casefull searching sped the whole process up considerably.
What I think that happens is that InStr() first converts both strings to
either upper or lower case, and only than does the search. While that
isn't a problem for relativly short strings, the conversion does take some
time when you throw 25 MB at it ...
... especially when you do that in a loop which finds over 40,000 .
Hence that reading the file line-by-line and than doing the caseless InStr()
sped the process up.
The whole process using the 25 MB string still takes several seconds to
complete though. Oh well.
Regards,
Rudy Wieser