Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scripting.Dictionary Experience? (MOD XP)

    i am having a 'funny' experience with the Scripting.Dicitionary. I have an array of 3 S.Ds, each of which is of the form Keys(string), Items(Long).
    The first SD is 1600 elements, the 2nd 8700, the 3rd 14000. Accessing the elements of the smallest SD takes reasonable time, but for the larger ones, the access time is _significant_.

    Anyone point me in the direction of an explanation / documentation?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    Just an opinion: I don't think the scripting.dictionary object was meant for "arrays" of that many elements. I use it for organizing named collections of far fewer items. I have no idea what the FSO is doing internally (or where for that matter), but you must be disk I/O bound if you're slow with thousands of items. Sounds like a job for an indexed db tables.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    Thanks Kevin ~ the performance of the dictionary is at best O(log N) depending on whatever the (hidden) search method is. For small N, it runs well. As the number of elements N increases, performance goes over a cliff. What is disturbing is that there is no way to access individual elements of the dictionary without using Keys(i), so I suspect there are unnecessary lookups, and it doing double work.

    I am considering alternative data structures; do you have any ideas as to an indexed table's O() performance?

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    I am not an engineer and do not play one on TV. I wouldn't know how to measure O() performance even if I did own a slide rule.

    All I know is that an Access database or SQL for that matter will return sub-second response time on an indexed record lookup for tables with thousands of records. Sorry, I don't have a db with millions of records to test. Maybe Char can chime in on this one.

    (What is O()?)
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    I *am* an engineer and that's why I talk like this. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    'O()', pronounced Big O Notation, is a way to rank various algorithms.

    Given an algorithm 'x' with a collection of data of size N, possible measures would be expressed:
    O(N) = constant e.g., array access which is independent of N
    O(N) = log N, e.g. binary lookup (log is to base 2)
    O(N) = N linear e.g. start at 0 and access each element in turn till you find it
    O(N) = N^2 e.g. the distance formula. This kind of algorithm gets expensive real fast

    It sounds like an indexed lookup is close to O(N) = constant, which is *ideal*.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    Thanks for taking the time to bore me to tears. Just kidding. Actually, I wish I were an engineer. Sounds like an old folk song, huh?

    If I had the college days to do over again, I'd be majoring in mechanical or electrical engineering. I loved all the math and chemistry stuff in Rocket Boys -- but only tolerated it when I was that age. I got to sort of relive my youth in that book. Only I never got quite as far as Homer did.

    S=1/2at^2
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    Not only are we boring, but we irk folks when we insist on measuring things, like performance. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    May the force be with you (nyuck nyuck)

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scripting.Dictionary Experience? (MOD XP)

    Unh-uh! <img src=/S/nope.gif border=0 alt=nope width=15 height=15> Not me. I'm allergic to formulas I can't understand, and I never got to take either calculus or statistics (had to settle for trig and finite math). <img src=/S/flee.gif border=0 alt=flee width=25 height=25>
    Charlotte

  9. #9
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    Taking the hint... i will NOT explain those formulae. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    So how do VBers measure performance of their code? [That's why I built my Meter]

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scripting.Dictionary Experience? (MOD XP)

    Um ... by whether we get paid?

    Since many (most?) of us are not engineers, we tend to do quick and dirty testing rather than serious, in-depth analysis. Once we find tools and techniques that turn in reasonable performance, that's what we use. PCs today are so fast that unless the user notices a delay, it may not be worthwhile chasing the "fastest" solution unless the application requires that kind of speed for technical reasons. None of mine do. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Does your meter also tell you how long it took you to test the speed of various data structures? <img src=/S/wink.gif border=0 alt=wink width=15 height=15>
    Charlotte

  11. #11
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    Ah yes, for pay, a crucial point, since that IS the bottom line. In fact, the "solution" that i am working on is something that i would like to sell, and it is such a <img src=/S/oink.gif border=0 alt=oink width=15 height=15> that *I* wouldn't buy it. That's my "marketability" test.

    Of course, speed is not everything; faster solutions often take more space, and more time to produce. I'm not directly measuring the latter (yet), but the Xybernaut (a wearable computer) is produced & sold here in No. Virginia . If i can get it to monitor my vital signs, ... non-invasively, that is...

    What I found "interesting" was the Stack implementation in Getz's book, which is implemented with a linked list. Rewriting it using an array gave me a 5-time speedup. But that one was pretty obvious if you have experience with these things, and took almost no time. Well, a couple of hours.

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scripting.Dictionary Experience? (MOD XP)

    Examples in books aren't necessarily the most efficient way to do something. They're there to show how to use a technique and exposition sometimes takes precedence over efficiency. <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15> Didn't I hear something about the Xbernaut being faster than a speeding bullet ...? <img src=/S/devil.gif border=0 alt=devil width=15 height=15>
    Charlotte

  13. #13
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    <hr>Does your meter also tell you how long it took you to test the speed of various data structures?<hr>
    A very pertinent point.

    In an effort to clean up my act and understand both arrays and datatypes I constructed the attached workbook. What it tells me is that it's almost not worth my time worrying about how I load data into an array - but just to do it the fastest way I can tap it into the vbe. I must have spent the best part of a day playing with this and whilst I think I have got some conclusions from it, I know it'll be a long time before I reap the benefits of the time spent playing with it.
    Attached Files Attached Files

  14. #14
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    Faifax, Virginia, USA
    Posts
    542
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Scripting.Dictionary Experience? (MOD XP)

    One of the benefits is that now you KNOW. The expense is tuition that we programmers continue to pay. You also have to include the time spent posting in this forum.

    i would guess by looking at the size of the array (N=7) that it is too small to display 'difficulties'. 'Advanced' algorithms are written to deal with cases when N is 'large'.

    But now i will have to retire the joke i was planning: 'How many VBers does it take to change a lightbulb?' Answer: 'Who knows? No one ever measured it'.

    Or at least change the punchline to <img src=/w3timages/censored.gif alt=censored border=0> uhh... let me work on that ... <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

  15. #15
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Scripting.Dictionary Experience? (MOD XP)

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> How about to "Who knows? They're still trying to measure the algorithm to find the fastest method." <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •