Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #12328

Re: Why does a loop using instr() and mid() get slower on larger data ?

Path csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From "Mayayana" <mayayana@invalid.nospam>
Newsgroups microsoft.public.scripting.vbscript
Subject Re: Why does a loop using instr() and mid() get slower on larger data ?
Date Sat, 2 Jan 2021 17:27:47 -0500
Organization A noiseless patient Spider
Lines 45
Message-ID <rsqs1f$5le$1@dont-email.me> (permalink)
References <rspm4t$1pm1$1@gioia.aioe.org> <rspt2m$613$1@dont-email.me> <rsq4fr$2tr$1@gioia.aioe.org> <rsqku7$ksc$1@dont-email.me> <rsqnho$157m$2@gioia.aioe.org>
Injection-Date Sat, 2 Jan 2021 22:27:59 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="9730b514082071b81266d08f6dc73fd7"; logging-data="5806"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Al2gKtQHmz6dYz2e9IJYDzalrPFYKmsA="
Cancel-Lock sha1:VcYNySNc+1cjleDQ0v/nKHUcHz8=
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.5512
X-Newsreader Microsoft Outlook Express 6.00.2900.5512
X-Priority 3
X-MSMail-Priority Normal
Xref csiph.com microsoft.public.scripting.vbscript:12328

Show key headers only | View raw


"R.Wieser" <address@not.available> wrote

| And I noticed you mentioned 0.14 seconds on a 100MB file (I first thought
| you said 14 sec).   Here a repeated search on just a 5MB file gave me
| between 2 and 5 results a second, or between 200 and 500 mSec.     I would
| have expected that with a much larger datastring it would become a 
multiple
| of that.
|

  I don't know. InStr is incredibly fast. I suspect the
wrapper bloat is much of the time. You have to tell
WScript to do it. WScript has to run the operation.
The string must be converted to BSTR. It all adds up.
And I suppose our systems may vary.

 I just tried loading the bible. 4.29 MB of plain text.
I added "wordyyy" near the end and looked for that.
Position: 4,497,580  Time: 0
  It didn't register as being enough time to measure.
But if you're doing multiple searches that introduces lots of other
variables.

 So I tried this loop with the same Bible text:

pt2 = 1
pt1 = 1

x = 0
t1 = Timer
Do Until pt1 = 0
  pt1 = InStr(pt2, s1, "John", 0)
  pt2 = pt1 + 1
  x = x + 1
Loop

t2 = timer
MsgBox x - 1 & vbCrLf & (t2 - t1)

 It returns 140 instances, found in 0 seconds. Interesting.
So once all the overhead slop is dealt with, the looping
code seems to take almost no time at all.


Back to microsoft.public.scripting.vbscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Why does a loop using instr() and mid() get slower on larger data ? "R.Wieser" <address@not.available> - 2021-01-02 12:41 +0100
  Re: Why does a loop using instr() and mid() get slower on larger data ? "Mayayana" <mayayana@invalid.nospam> - 2021-01-02 08:39 -0500
    Re: Why does a loop using instr() and mid() get slower on larger data ? "R.Wieser" <address@not.available> - 2021-01-02 16:46 +0100
      Re: Why does a loop using instr() and mid() get slower on larger data ? "Mayayana" <mayayana@invalid.nospam> - 2021-01-02 15:26 -0500
        Re: Why does a loop using instr() and mid() get slower on larger data ? "R.Wieser" <address@not.available> - 2021-01-02 22:11 +0100
          Re: Why does a loop using instr() and mid() get slower on larger data ? "Mayayana" <mayayana@invalid.nospam> - 2021-01-02 17:27 -0500
            Re: Why does a loop using instr() and mid() get slower on larger data ? - found it (I think) "R.Wieser" <address@not.available> - 2021-01-03 08:58 +0100
              Re: Why does a loop using instr() and mid() get slower on larger data ? - found it (I think) "Mayayana" <mayayana@invalid.nospam> - 2021-01-03 08:54 -0500
                Re: Why does a loop using instr() and mid() get slower on larger data ? - found it (I think) "R.Wieser" <address@not.available> - 2021-01-03 16:01 +0100
                Re: Why does a loop using instr() and mid() get slower on larger data ? - found it (I think) "Mayayana" <mayayana@invalid.nospam> - 2021-01-03 12:51 -0500
                Re: Why does a loop using instr() and mid() get slower on larger data ? - found it (I think) "R.Wieser" <address@not.available> - 2021-01-03 19:26 +0100
          Re: Why does a loop using instr() and mid() get slower on larger data ? "Mayayana" <mayayana@invalid.nospam> - 2021-01-02 17:43 -0500
  Re: Why does a loop using instr() and mid() get slower on larger data ? JJ <jj4public@gmail.com> - 2021-01-03 02:47 +0700
    Re: Why does a loop using instr() and mid() get slower on larger data ? "R.Wieser" <address@not.available> - 2021-01-02 21:47 +0100

csiph-web