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


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

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

From "R.Wieser" <address@not.available>
Newsgroups microsoft.public.scripting.vbscript
Subject Re: Why does a loop using instr() and mid() get slower on larger data ?
Date 2021-01-02 16:46 +0100
Organization Aioe.org NNTP Server
Message-ID <rsq4fr$2tr$1@gioia.aioe.org> (permalink)
References <rspm4t$1pm1$1@gioia.aioe.org> <rspt2m$613$1@dont-email.me>

Show all headers | View raw


Mayayana,

> For concatenation or adding to a string:

I know that that can get rather slow quicly.  But I'm not adding anything to 
the origional data, just instr() to find something and using mid() to copy a 
small part following it (and than work on it).

>  VBS doesn't have the Mid statement, only the function.

:-) Yup.  Nice aint it ?   You have to grab-and-store the (huge) strings 
before and after what you want to replace and than glue them together with 
the new string in between.

>  If you see a lag just reading

That what I have, just while reading.

And the odd thing is that just finding a string in the first few lines slows 
down depending on the size of the to-be-searched string.    I have no 
explanation for that, other than that it does /something/ involving the size 
of the string.   I would not know what though, as variant strings are 
size-prefixed (they can have embedded NULs)

> But I do find that searching case-insensitive is much slower.

Thats to be expected.   Thanks for reminding me though.  I don't think that 
the file contents are case sensitive, so I could just lcase() the lot of it 
and have some speed gain.

>  I just tried loading a 100 MB text file and looking
> for a string near the end. It took .14 seconds

:-)  To many variables.   Loading and searching together ?  ReadLine or 
ReadAll ?

> On the other hand, if you need to deal with 25 MB files
> enough to matter then maybe something else is wrong.
> No *typical* text file should need to be that big.

It definitily is a typical textfile ... for an OpenStreetMap .OSM datafile 
that is. :-)

I'm trying to convert such an dataset into a usable image.   The first step 
was to go thru all the "node" elements and plot their coordinates.

Just to check I rewrote the script to read the file line-by-line and see 
what would happen.  The end result is a few times faster than reading all of 
it into memory and than have a go at it.   I did not quite expect that ...

Rgeards,
Rudy Wieser

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