mIRC Home    About    Download    Register    News    Help

Print Thread
#115041 21/03/05 06:21 AM
Joined: Mar 2005
Posts: 2
N
nkitty Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
N
Joined: Mar 2005
Posts: 2
ok, what this script does is it just times how fast your script can do four operations 1000 times and yeah.

/999test {
//set %ba $ticks
/set %i 1
:[b][/b]one
//set %bc $ticks
//echo Count up to: %i
//inc %i 1
//set %test $calc(%bc - %ba)
if (%i < 1000) goto one else | //msg #channel $me took $calc(%test / 1000) seconds to add one to one each time to get to 999(while reseting time each time).
}

now, the problem is that it does strange things:
one of the users I gave the script to who has a slower machine than another got a faster speed than the faster machine.
results:
user 1: .51 seconds
user 2: 1.563 seconds
another is if you start the script and immediately switch the window, the speed is much faster(the slowest machine got the second highest speed doing this)
I believe something happens to the $ticks when you do the window switch, but I don't know what. this is mostly just a question of why it does this.. so any answers are appreciated.

#115042 21/03/05 08:21 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
The reason is that your loop is displaying something mostly, and is performing differently on peoples machines is due to how there machines are at that moment.
Example
(1) Increase the loop to a more noticable amount using 10,000 instead of 1000
(2) maximize mirc and maximize the current window then /999test and record result
(3) now make the current window one quater of the maximized size (1/2 width and 1/2 height) then /999test, compare the results (this one well be quicker)


Reason : you are displaying stuff inside your loop, this means that the Windows OS is instructed to redraw a window everytime you go through the loop, the less to redraw the faster.

Other Reasons : Windows is a mutithreaded & mutitasking (well almost) OS, so if you switch windows to another application, the new current application recieves a greater % of the CPU time, so mirc gets less meaning it takes longer to complete. (this is dependent on how windows is setup but most are setup like this)

* Thats the simplest I can explain it, it can get alot more complexe of course

#115043 21/03/05 08:30 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
(Since it's an alias definition you can remove the /'s)

The script you made does not (only) test how long it takes to count to 100, it also counts the time for 2000 /set and 1000 /inc commands, and most importantly 1000 screen updates (/echo). You have to realize that updating the screen takes a long time in comparison to those /set's, so this is really the most important factor. If the windows where those echo's go is hidden, no screen updates have to be done, so there is less to do, so it takes much less time...

In the script below I added a custom window @blah, you can try to see the difference between this script with the red -n there and without it, making the window minimized or visible.

999test {
if ($window(@blah)) window -c @blah
window -n @blah
var %ba = $ticks
var %i = 1
while (%i < 1000) {
echo @blah Count up to: %i
inc %i 1
}
var% test = $calc($ticks - %ba)
msg $chan $me took $calc(%test / 1000) seconds to count to 1000
}

#115044 21/03/05 04:06 PM
Joined: Mar 2004
Posts: 540
A
Fjord artisan
Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
havent tested it, butjust glancing over and you typoed near the bottom
var% test = $calc($ticks - %ba)
var %test = $calc($ticks - %ba)

#115045 21/03/05 04:54 PM
Joined: Mar 2005
Posts: 2
N
nkitty Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
N
Joined: Mar 2005
Posts: 2
I see.. thanks alot guys. very appreciated.


Link Copied to Clipboard