Re: stupid question



mayayana wrote:
I don't think the point is to be able to "boast
of the best method". Personally I find optimizing very
interesting and useful. There's not a heck of a lot of
optimizing that can be done in script, but as a matter
of valuing good design and general mindfulness in one's
endeavors, I like to try to optimize wherever I can.

There's a very interesting site for VB optimizing that
compares different methods:
http://www.xbeat.net/vbspeed/
The differences can often be very significant in "real
world" usage. Unfortunately, though, while VB is a
somewhat inefficient tool that can be optimized to very
high efficiency, VBScript is a very inefficient tool that
can only be minimally optimized.


In the case at hand I doubt that, in most scenarios,
there will be a significant difference. On the other hand,
I didn't know exactly what the OP was doing...so why
not optimize? Why not try to understand how the code
works and be articulate about it?

I don't happen to have a list of 23,000 files handy, so
I don't know what the "insignificant" difference is that you
found. A couple points that might be relevant:

* A tiny difference in checking on one file could translate
into a notable difference if thousands of files need to be
checked against the list.

* I don't know how accurate the time method is for measuring
tiny durations. It may not even be accurate to 100 ms. I really
have no idea. But given that a single search of an array or string
is involved, extreme accuracy down to 1 ms would be needed
to assess real world implications.

It may be that there's virtually no difference, even where
tens of thousands of files are checked for tens of thousands
of names. Instr, array accessing, and string comparison are
all very fast. That result would still be interesting to know, as
far as I'm concerned. Isn't it more interesting to know the facts
than to know who gets "boasting rights"?

These questions and comments are exactly the reason I performed my own
testing and included the code I used to perform the testing (so anyone can
perform their own testing if desired). Most anyone with a Windows computer
has at around 9000 files available in their Windows folder alone (varies by
size of TIF). That was just a small list taken from one of my photo folders
but a much larger list can be aquired from the full drive.

At cmd line type...
dir/a-d/b/s c:\ >list.txt

If you want to know how many files are in the list simply type...
find /c ":" list.txt

And here is a typical output that I received on my very slow Windows 98
machine using the test code that I posted.

Array and variable are now in memory...
Array Method 1.15740740740666E-05
Instr Method 1.15740740740805E-05

Results will vary from machine to machine and even running the code several
times on the same machine, and at different times. When it comes to
comparing time, it is recommended to rerun a test several times.

Basically, I'm not boasting either method is better per se. I'm just saying
perform your own testing, as I have done, to "know the facts". <shrug>

BTW, I consider you a very helpful programmer.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

.



Relevant Pages

  • Re: stupid question
    ... Personally I find optimizing very ... But given that a single search of an array or string ... Instr, array accessing, and string comparison are ...
    (microsoft.public.scripting.vbscript)
  • Re: Global array operations: a performance hit?
    ... optimizing array expressions. ... such array temporaries, ... There is currently no warning and AFAIK no request for such a feature. ...
    (comp.lang.fortran)
  • Re: stupid question
    ... Personally I find optimizing very ... But given that a single search of an array or string ... My own view here is that, if a bit of tweaking can make 1% of your code run ... if a script that is run once a week to update a shared phonlist ...
    (microsoft.public.scripting.vbscript)
  • Re: Global array operations: a performance hit?
    ... when using array operations you have additional information ... which is not always the case in DO loops. ... optimizing array expressions. ... The compiler has to ...
    (comp.lang.fortran)
  • VC++ optimization problem
    ... basically a matrix-vector multiplication at its core, ... Done in 0.42 seconds (2398.55 iterations/sec) ... which claims to have the same optimizing compiler ... The windows version was compiled with this command line: ...
    (microsoft.public.vc.language)

Loading