mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2003
Posts: 30
R
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 30
In my script I had used text files for majority of the settings and am considering changing to hash tables since im redoing most of it. Is the speed difference worth the trouble to change everything over to hash tables?

Also, would there be any noticable resource difference when using hash tables since they would all be in memory compared to just reading when its needed?

Joined: Jan 2003
Posts: 94
S
Babel fish
Offline
Babel fish
S
Joined: Jan 2003
Posts: 94
well it depends on the size of all your data

if you have large amounts of data then i suggest using hash tables because they can recall information (ms) faster


-
E-Mail: mirc_sabby@hotmail.com
Network: irc.enterthegame.com
Channel: #Helpdesk
Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
I use hash tables for big and small things that I don't need mIRC to remember once it is closed. There's alot of hooharr about whether a hash table either should be or is worth using for small things. Many will say it's not and use local var instead though having changed alot of local vars over to hash tables I say that there is a noticeable difference in performance. As for text files and I assume you mean .ini's then hash tables plainly crap all over them in terms of speed. A .ini is good for script settings though as there is no need to issue further commands to save the data when you finish with mIRC, it's already there in the file.

Joined: Jan 2003
Posts: 30
R
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 30
Ok. A while back I had switched to both plain text and ini files for settings. I just got tired of having so many vars. On my pc I do not notice any real lag, but when I put my script on a p100, there is a fair amount of lag and I think its from the script reading from the files for a lot of different things.

An example: I have a setting for on ban that says if I should warn the users, kick them, or kick an ban them. So when I am banned, it reads from a file to see what it should do. While I want that to be there every time I start mirc, I would think that there would be a slow down from having to read from the file. But on the other hand, I would have to load the hash file and save it on startup and close.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Reading from a file in an event is generally not a good idea, especially something like on BAN where you can get multiple consecutive occurences. Hash tables or variables would be more fitting. Just think that loading/saving a hash table means reading from a file a few times, whereas storing settings in a file means reading from a file hundreds, maybe thousands of times during the course of a mIRC session - at critical moments aswell.

Simply load the settings on start, then save the settings to file any time they make a change (to prevent those changes being lost in the event of a crash) and of course on exit. The extra memory required to hold the hash table is negligable.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Loading two text lines into hash table, would be even faster than performing $read twice. I think the reason is, because each $read or write first opens the file, then reads a line and closes it, while commands like /filter, /loadbuf or /hload needs to open and close it only once smile

Joined: Jan 2003
Posts: 30
R
Ameglian cow
OP Offline
Ameglian cow
R
Joined: Jan 2003
Posts: 30
Ok, I will be converting several things to hash tables. Thanks for all the input everyone.


Link Copied to Clipboard