mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2006
Posts: 93
Babel fish
OP Offline
Babel fish
Joined: May 2006
Posts: 93
i know if i have something like this
Code:
if ($gettok($read(%file,%line)),2-,32) == asd) {
  echo -a $ifmatch
}
 

use echo -a $ifmatch is faster than use echo -a $gettok($read(%file,%line)),2-,32) but if i have
Code:
if (%var) {
  echo -a $ifmatch
}
 

is faster the $ifmatch or the %var? the $ifmatch is a function that returns the value of a var? so echo -a $ifmatch is slower than echo -a %var?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Here's how mIRC would go through your examples.
First example:
The line is read from the file
The line is parsed from the first space character to the end of the line
The parsed information is compared and the $ifmatch identifier is set/unset
the contents of $ifmatch are returned

This is faster, than echoing $gettok($read(%file,%line)),2-,32) because mIRC doesn't have to go through those first two steps a second time for the information to be displayed.

2nd example:
The variable is set
check the variable, if there is information then echo the variable

Re-writing your first code and going with the least amount of processing time, probably would get you

Code:
 echo -a $iif($gettok($read(%file,%line),2,32) == asd,$v2) 

$v2 will return asd if there's a match, but it's faster than using $ifmatch (which has basically been replaced with $v1) since the setting of $v2 does not require mIRC to read and then parse the line before setting the identifier

Joined: May 2006
Posts: 93
Babel fish
OP Offline
Babel fish
Joined: May 2006
Posts: 93
i do this test
Code:
test {
  window @test
  var %k 10000

  var %tk $ticks
  while (%k) {
    aline @test $ifmatch
    dec %k
  }
  var %t1 $calc($ticks - %tk) 

  aline @test --------------
  var %k 10000

  var %tk $ticks
  while (%k) {
    aline @test %k
    dec %k
  }
  var %t2 $calc($ticks - %tk) 

  aline @test --------------
  var %k 10000

  var %tk $ticks
  while (%k) {
    aline @test $ifmatch
    dec %k
  }
  var %t3 $calc($ticks - %tk) 

  aline @test --------------
  var %k 10000

  var %tk $ticks
  while (%k) {
    aline @test %k
    dec %k
  }
  var %t4 $calc($ticks - %tk) 

  echo -s ifmatch-> %t1 / %t3
  echo -s var-----> %t2 / %t4
}
  

(i do 2 series for $ifmatch and 2 for the var because during the creation of the window mirc is slow and the first one is slower and in the first test with %k = 100 the time of the first one is always the double of the second one)
and these are the results
Code:
with %k = 10000
ifmatch-> 578 / 547
var-----> 531 / 547
ifmatch-> 593 / 562
var-----> 532 / 547
ifmatch-> 593 / 532
var-----> 547 / 531
ifmatch-> 594 / 562
var-----> 531 / 547

with %k = 100000
ifmatch-> 5656 / 5593
var-----> 5688 / 5563
ifmatch-> 5578 / 5391
var-----> 5375 / 5391

with %k = 1000000
ifmatch-> 56125 / 55640
var-----> 55610 / 56891

it seems that %var is a little faster than $ifmatch but maybe this test is not the best way...

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
%var is going to be faster, because the steps that mIRC has to go through to set the variable, only have to be done once, then the variable is echoed, as with $ifmatch (or $v1) the steps have to be gone through a minimum of two times.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
$ifmatch/$v1 and variables are equally fast for all practical purposes. Built-in identifiers (especially ones without parameters) are generally very fast because they usually behave like variables, ie they fetch a certain (ready) value from memory, for example $chan, $nick (NOT $chan() or $nick()), $v1 etc.

Any speed difference between $v1 and %var is so small that it shouldn't concern you.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: May 2006
Posts: 93
Babel fish
OP Offline
Babel fish
Joined: May 2006
Posts: 93
Thanks for the info wink


Link Copied to Clipboard