Effective max size of arrays

Posted by Fletchling on Fri 31 Mar 2006 10:12 AM — 6 posts, 21,741 views.

Australia #0
G'day

I have an idea I'd like to try for my mud, but it involves a bunch of arrays of about a 1000 keys each. Any ideas on how I'd measure the performance impact?

In fact, ideas on how I should ask the question (I don't know what I don't know) is probably a better question.

Fletchling
USA #1
I'm not sure how much a "bunch" is, nor exactly what you plan on doing with the arrays, but several thousand keys shouldn't be a problem.

What matter are things like how many times you loop over the entire array, if you're just doing key lookups, what scripting language you choose, etc.
Australia #2
bunch = metric term for lots

script language = Lua (I'm sold on Lua)

no loops interrogating each array, just a serial read of each key and value, then some small processing for display formatting. Since the outcome is informational, that is I'm at a point in the mud where I want to make decisions, not millisecond client response, I'm happy with the whole operation taking a second or two.

I was more worried whether there was an overhead to MC just by having a bunch* of arrays. If the pilot works to the satisfaction of my captive bug tester, the arrays may be extended to max size of 10k elements.

Oh, the purpose of this is to explore possibilities for mapping, but that topic has been beaten to death elsewhere so I thought to keep this post to just the code related issues.

*see above definition
Australia Forum Administrator #3
As Ksilyan says, the important thing is not having them but what you do with them. It is not so much whether MUSHclient will be slow, as whether Lua can handle it, and I would suggest that unless you are accessing millions of items a second, yes it will.

You could write a small test script in the immediate window, making as many table items as you expect (with random or fixed data) and then iterate through it and see how long whatever you are planning to do, takes.
USA #4
Everything Nick said holds; there's also another small consideration which is memory. If you're storing, say, a million keys, each pointing to an integer, you'll be using at least four megabytes of memory (if not in fact more like eight). Like I said, though, that's a fairly small consideration, because four or eight (or even twenty) really isn't a whole lot of memory.

But as Nick said, the best way to find out for sure is simply to run the script and see what happens. I suspect it won't be too bad, and I doubt it'll take a whole second, but again that depends on what exactly is being done to the data.
Australia #5
It's all true.
I created an array bigger than I can count and MC didn't blink. If the result of this work actually looks any good from a mud player's perspective, I'll post the purpose, method and outcome. First of all I have to get it past the captive bug-tester girl.

Thanks guys.
[doffs 'is 'at]