mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2003
Posts: 20
L
limp Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2003
Posts: 20
I'm just curious on how different scripts can go at different speeds. Lets say I'm in an opwar with somebody. What makes them beat me and what makes me beat them? Is there anyway I can modify how fast my script processes data? Also is there any real difference in hash and variables? I ask this because I was in an opwar with somebody that used variables and I use hash and they still crushed me, and when I say modify I mean the way my script is laid out and whether certain styles affect the speed of the data processing.

Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
I think the internet connection(speed/ping) is the biggest bottle neck in situations like that, not the mIRC script...
hash tables might be a bit slower to process...

just write your own testing aliases, set 10000000 vars and set 10000000 hashtable items and see which'll take longer



Code:
//if ( khaled isgod ) echo yes | else echo no
Joined: Dec 2002
Posts: 2,809
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
hash tables are MUCH faster than variables. A good hash table (and mIRC has relatively decent hash tables) has the ability to be the fastest method of data retrieval in existence.

Joined: Apr 2003
Posts: 18
N
Pikka bird
Offline
Pikka bird
N
Joined: Apr 2003
Posts: 18
yeah we learn in a simple Computer Science, Data Structures and Algorythms class that hash tables are very very very very very very fast smile

Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
hash tables might be a bit slower to process...

I agree with codemastr

Hash tables are pretty hard to knock over. They arn't ordinarily written to/read from text files which makes them zillions of times faster than global vars to begin with. Then of course is the amount of info that you can store in them.

Joined: Dec 2002
Posts: 39
V
Ameglian cow
Offline
Ameglian cow
V
Joined: Dec 2002
Posts: 39
How certain are you that mIRC variables aren't implemented as hash tables in the first place? They obviously need to be written to file at times, but that could easily be seldom enough not to be much of a problem.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
As you can already see, you're going to get numerous responses in the hashes-or-vars question. No matter how "leet" the replies look, I think you shouldn't take anything for granted. Benchmark both ways and make your own conclusions.

Regarding what's fast/faster/slower in scripting, generally, I'm afraid the only real picture you can get is by your own experience. Of course, taking into consideration what others have to say is always good, but secondary. Following rules regarding performance without understanding (or without having tested) them yourself is pretty much useless in the end.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
Well, yes seeing is believing. I know of a custom built security robot that can issue akills against an attack of thousands of warbots, based on information stored in one hash table, in a matter of one or two seconds. This sort of power could never be achieved with variables of any kind, and I dare to say regardless of the platform or application used.

Back at the level of the humble user, I run a couple of scripts that require raw events to be silenced while their information is diverted to dialogues and then for seemlessness and reliability purposes be available again in the normalmode of replying by echoing to the active window. I use hash tables for this because variables (local or global) cannot keep up with the responsiveness I want. It's a shame in a way because runnign a local variable requires less code, but that's just how it is.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Personally, I agree that hash tables are a lot faster when the number of items is quite large (although they're about equally fast when that number is small), simply because my tests have shown so. I wasn't arguing this though; my point was that nobody should take any opinion (including mine of course) on such things for granted, because no matter whom it is coming from, it might be inaccurate. Either because anybody can make mistakes or simply because one can't know what mirc does internally. In the end, the only opinion you can rely on is $ticks's.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Dec 2002
Posts: 39
V
Ameglian cow
Offline
Ameglian cow
V
Joined: Dec 2002
Posts: 39
"This sort of power could never be achieved with variables of any kind, and I dare to say regardless of the platform or application used."

Excuse me but I must ask:
How on earth do you defined a 'variable' in general? How do you generally think a 'variable' is implemented (in general as well as in mIRC)? What kind of beast is this magical 'thing' called a 'variable'?

I really am curious.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Re-reading your first paragraph more carefully (after reading vague's reply) I want to point out, if it wasn't already clear, that I am talking about mirc. I'll be damned if I know what you are talking about though.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Apr 2003
Posts: 20
L
limp Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2003
Posts: 20
How would I test the speed? What methods are there to see which is faster? I'm just curious

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Use $ticks for this. $ticks returns the number of milliseconds since your last boot. The idea is to record the $ticks value before the specified routine is run, then record $ticks again after the routine is finished. Subtracting the first number from the second tells you how many milliseconds your routine needed to complete. Example:
Code:
  ....
  var %a = $ticks
  myalias
  echo -s /myalias took $calc($ticks - %a) msecs to complete.
Of course, there can be anything between the 1st and the 3rd line, not just a single alias. The advantage of this method is that $ticks will always keep increasing once every millisecond, regardless of what you do in mirc, because its value is updated by Windows. This makes it accurate enough for your purposes.

In case you want to compare the speed of two aliases that have similar performance, you can use the same method but instead of calling each alias once, you call it a large number of times by putting it in a while loop. This way, the speed difference is multiplied by N (where N is the number of iterations in the loop), so it shows up. For example, if the difference in speed between two aliases is 1 msec, then in 1000 iterations, it becomes 1000 msecs, which makes the result safe enough. Remember that a few milliseconds difference isn't safe enough to compare the speed of two aliases, because of fluctuations in their execution time. For example, an alias might take 13 msec once and 16 msec next time. If another alias takes 14msec and 15 msec respectively, there's no way to tell which is faster. Putting both in a loop will make any existing difference show up.

When benchmarking anything in mirc, try to benchmark only the part of the code that interests you, making sure you have the least possible number of irrelevant variable assignments, if statements etc in between. Make sure that %a is set to $ticks right before the code you want to benchmark and that the new $ticks value is grabbed right after the the code is finished. If you want to echo the result at a later time, set a second local variable to $ticks after the routine finishes and use $calc(%b - %a) later.

In case two routines are very similar, speed-wise, things get a little harder and a lot of other factors must be taken into consideration when designing the benchmark. I won't get into details here, but remember that the accuracy of benchmarks in mirc is inherently limited.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard