• Scripting.Dictionary Experience? (MOD XP)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Scripting.Dictionary Experience? (MOD XP)

    Author
    Topic
    #371458

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #591037

      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.

      • #591067

        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?

        • #591291

          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()?)

          • #591298

            I *am* an engineer and that’s why I talk like this. grin

            ‘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*.

            • #591334

              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

            • #591341

              Not only are we boring, but we irk folks when we insist on measuring things, like performance. grin

              May the force be with you (nyuck nyuck)

          • #591369

            Unh-uh! nope 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). flee

            • #591530

              Taking the hint… i will NOT explain those formulae. grin

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

            • #591637

              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. shrug

              Does your meter also tell you how long it took you to test the speed of various data structures? wink

            • #591692

              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 oink 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.

            • #591699

              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. hmmn Didn’t I hear something about the Xbernaut being faster than a speeding bullet …? devil

            • #591770

              [indent]


              Does your meter also tell you how long it took you to test the speed of various data structures?


              [/indent]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.

            • #591832

              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 censored uhh… let me work on that … evilgrin

            • #591861

              laugh How about to “Who knows? They’re still trying to measure the algorithm to find the fastest method.” evilgrin

    Viewing 0 reply threads
    Reply To: Scripting.Dictionary Experience? (MOD XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: