
|
|
benchmarks
snippets
scripts
tutorials
links
|
Everything is located at this page. You can save it if you want to. You can use it anywhere if you want to. You can give me credit if you want to. You can blame me if it sucks if you want to. As long as you know what it does. Email me for comments. Im not perfect so I may be wrong with everything. Please remember me in the future and tell your kids that this stupid dude made lame benchmarks of codes in mirc. Primarily, i want to help scripters make faster scripts. If im wrong in something, make a point.
NOTE: some comments are marked with ::mp3 which means i tested it while listening to an mp3 (yes, only 1 mp3). i just didn't realize how it affects the speed since it's kinda boring listening to nothing. maybe ill re-test them but for now, im just lazy. by the way, my pc specs are, celeron 300, 64mb ram, 4mb vcard.
|
This is the code that i used for benchmarking. The idea is to call $b 5 times. $b(ctr), ctr is the loop counter. You'll probably get the point if you're a scripter. I don't know how effective or worthless this is but unless someone cares, this is how i did it.
NOTE: i tested it several times (calling /benchmark atleast 7-10 times) to make it a bit more accurate. then i took note of the fastest. sorry if i have mistakes.
alias benchmark {
var %c 5,%a,%b,%d,%e 1000 (stated if another value is used)
echo -
while (%c) {
%a = $b(1000)
%b = $calc(%a + %b)
%d = $instok(%d,%a,1,32)
dec %c
}
echo benchmark: %d total: %b ave: $calc(%b / 5)
}
;%a = value of $b, %b = total of %a, %c = benchmark loop counter
;%d = recorded values of %a, %e = loop counter for $b (i use $b(1000). this is for clarifications if needed be)
;average of 100ms per 1000 counter
alias b {
var %a,%b,%c $1,%d
%a = $ticks
while (%c) {
%b = put value here (used everytime otherwise stated)
dec %c
}
%a = $ticks - %a
return %a
}
;%a = $ticks, %b = dummy variable, %c = loop counter, %d %e..%z can be used if needed
* new note: as much i wanted to fix some "mistakes", im kinda lazy. it's not making any serious difference anyway. these benchmarks are dated back to sept.26.2002. just copy pasted and changed a little bit to fit the new layout.
$exist vs $isfile vs $isdir
returns true
$exists benchmark: 2211 2149 2150 2150 2157 total: 10817 ave: 2163.4
$isfile benchmark: 2156 2177 2177 2167 2160 total: 10837 ave: 2167.4
$exists benchmark: 325 321 336 329 319 total: 1630 ave: 326
$isdir benchmark: 352 342 333 355 331 total: 1713 ave: 342.6
returns false
$exists benchmark: 4266 4269 4271 4357 4273 total: 21436 ave: 4287.2
$isfile benchmark: 4286 4290 4419 4301 4292 total: 21588 ave: 4317.6
$exists benchmark: 1120 1119 1128 1126 1121 total: 5614 ave: 1122.8
$isdir benchmark: 1163 1145 1157 1169 1152 total: 5786 ave: 1157.2
purpose:
checking for files/folders' existence
comments:
tested on c:\abcdefg\lyrics\eretzvaju - evil zone - kiss in the dark.txt with 339 other txt files in it.
tested c:\abcdefg\lone wolf and cub\ with 92 other folders in it.
it seems $exists is faster.
::mp3
$true vs 1 vs a | $false vs 0 vs $null
$true benchmark: 180 183 186 187 201 total: 937 ave: 187.4
1 benchmark: 183 182 174 204 173 total: 916 ave: 183.2
a benchmark: 175 178 196 169 177 total: 895 ave: 179
abcde benchmark: 180 172 180 181 189 total: 902 ave: 180.4
abcdefghijklmno benchmark: 200 189 181 185 168 total: 923 ave: 184.6
$false benchmark: 137 135 131 144 130 total: 677 ave: 135.4
0 benchmark: 134 133 127 145 138 total: 677 ave: 135.4
00000000 benchmark: 166 176 182 179 178 total: 881 ave: 176.2
$null benchmark: 139 169 150 138 143 total: 739 ave: 147.8
purpose:
what is the truth
comments:
tested using if (condition) { %b = 0 }
if you're using the if statement for on/off purposes, just use 1 or any single character for on, and 0 for off.
i used if (c) { %b = 0 } rather than %b = $iif(c,0) because it's faster.
::mp3
$regex(#text,(#)) vs #* iswm #text
$regex() benchmark: 264 254 267 285 257 total: 1327 ave: 265.4
#* iswm #text benchmark: 228 191 202 217 203 total: 1041 ave: 208.2
purpose:
finding if text starts with # (other characters can be used)
comments:
tested using if (condition) { %b = 0 }
im not familiar with regular expressions as i am writing this. they say regular expressions are powerful and faster when matching large words or things like that.
::mp3
%var vs $1
using %b = %e/$1
%var benchmark: 150 143 155 143 147 total: 738 ave: 147.6
$1 benchmark: 147 156 145 155 144 total: 747 ave: 149.4
using if (%e/$1) { %b = 0 }
%var benchmark: 205 171 178 179 174 total: 907 ave: 181.4
$1 benchmark: 172 185 177 183 183 total: 900 ave: 180
purpose:
to check if there is $1 and if putting it in a variable is a lot faster.
comments:
%e was declared
not much of a test since there is only $1 (vs $1-) and it is a number value.
you can try yourself to set a higher loop counter. (of course you can. as if someone will try and stop you)
also try using 1 for $1. just try...
::mp3
$active ischan vs #* iswm $active
$active ischan benchmark: 190 175 180 170 170 total: 885 ave: 177
#* iswm $active benchmark: 180 175 179 186 195 total: 915 ave: 183
misc: instead of %b = 0, $chan vs $ifmatch is used
loop counter 1000
$chan benchmark: 180 174 181 179 176 total: 890 ave: 178
$ifmatch benchmark: 175 175 180 180 180 total: 890 ave: 178
loop counter 5000
$chan benchmark: 909 905 906 890 900 total: 4510 ave: 902
$ifmatch benchmark: 890 915 920 915 915 total: 4555 ave: 911
purpose:
checking if active window is a channel
comments:
tested using if (condition) { %b = 0 }
$right(%var,4) vs $gettok(%var,2,46) vs $gettok(%var,$numtok(%var,46),46)
using %d = voodoodoll.txt
$right(%d,4) benchmark: 216 215 225 235 210 total: 1101 ave: 220.2
$gettok(%d,2,46) benchmark: 219 216 215 239 210 total: 1099 ave: 219.8
$gettok(%d,$numtok,46) benchmark: 250 265 255 275 255 total: 1300 ave: 260
using %d = im trying to get some sleep here.txt
$right(%d,4) benchmark: 220 215 215 225 220 total: 1095 ave: 219
$gettok(%d,2,46) benchmark: 230 220 210 221 219 total: 1100 ave: 220
$gettok(%d,$numtok,46) benchmark: 260 265 275 260 251 total: 1311 ave: 262.2
purpose:
to check for file type
comments:
NOTE in $right i used == .txt, in $gettok i used == txt
a bit senseless. curiousity i guess. you might ask what's with $numtok. some filenames can contain any number of periods. it is to make sure you get the last token. anyway, use $right().
%var = 1 vs var %var = 1
%var benchmark: 130 125 124 126 125 total: 630 ave: 126
var %var benchmark: 154 150 156 155 150 total: 765 ave: 153
purpose:
declaring variables
comments:
tested using %b = 1
always declare local variables outside (before) a loop statement. i used to do that.
if () { statement } vs if() statement
{ statement } benchmark: 160 155 155 155 150 total: 775 ave: 155
statement benchmark: 140 145 140 140 135 total: 700 ave: 140
purpose:
enclosing statements in { }
comments:
tested using %b = 0
i had a habit of enclosing single statements in { } for clean coding (really? me?). again, curiousity speeds up the day.
alias vs alias -l
counter 5000
alias benchmark: 421 445 413 448 415 total: 2142 ave: 428.4
alias -l benchmark: 425 439 420 446 414 total: 2144 ave: 428.8
purpose:
declaring an alias
comments:
huh?
... i used alias b vs alias -l b. i don't know if a larger alias affects speed. i don't know how mirc handles this switch.
$color(Action) vs $color(Action text)
$color(Action) benchmark: 155 150 156 160 149 total: 770 ave: 154
$color(Action text) benchmark: 180 160 164 161 159 total: 824 ave: 164.8
purpose:
getting color values
comments:
using smaller names is faster. mirc can handle it anyway. lesser bytes too.
%c >= 1 vs %c > 0 | %c >= 0 vs %c > -1
counter 5000
%c >= 1 benchmark: 781 780 785 754 780 total: 3880 ave: 776
%c > 0 benchmark: 760 790 780 784 761 total: 3875 ave: 775
extra: %c benchmark: 641 626 650 645 629 total: 3191 ave: 638.2
%c >= 0 benchmark: 771 745 765 764 760 total: 3805 ave: 761
%c > -1 benchmark: 764 769 766 750 767 total: 3816 ave: 763.2
purpose:
while loops
comments:
using while (condiition) { %b = 0 | dec %c } (removing %b = 0 lessens time for about 30ms, i just included it anyway)
the first two had variations in result but seems to be no speed differences. if you're only waiting for %c to become 0 then use while (%c). of course, if you wanted it to stop when it's a negative integer then %c > 0. some scripts do so.
the last two seems justified. the way i saw the results, %c >= 0 is a bit faster.
echo $c vs c
counter 100
alias c echo Hello vs alias c return Hello
c benchmark: 134 150 136 131 133 total: 684 ave: 136.8
echo $c benchmark: 140 140 134 135 138 total: 687 ave: 137.4
$c benchmark: 145 135 135 135 132 total: 682 ave: 136.4
purpose:
i don't know.
coomments:
$c is the same as /c. just checked if there's a difference. well it's only 100 counters. i don't know what's stopping me from using 1000/5000. im sleepy i guess. /me goes to bed.
...
/me stands up, turns off the hard disk and monitor.
/me goes to bed.
/me stands up, goes to cr.
/me goes to bed.
/me stands up. turns on the monitor.
darn it. ok fine.
counter 5000
$c
benchmark: 7160 7196 7140 7155 7095 total: 35746 ave: 7149.2
benchmark: 7065 7111 7184 8046 7080 total: 36486 ave: 7297.2
benchmark: 7079 7135 7150 7021 7094 total: 35479 ave: 7095.8
c
benchmark: 6940 6955 7000 6979 6949 total: 34823 ave: 6964.6
benchmark: 7065 6955 7055 6996 7104 total: 35175 ave: 7035
benchmark: 7075 7015 6990 7095 6945 total: 35120 ave: 7024
echo $c
benchmark: 7110 7095 7170 7070 7120 total: 35565 ave: 7113
benchmark: 7176 7215 7085 7124 7840 total: 36440 ave: 7288
benchmark: 7130 7139 7196 7219 7121 total: 35805 ave: 7161
comment:
oh.. a slight difference. it's useful, let's say hadd hasht item $c where alias c return value instead of /c where alias c hadd hasht item Hello. ugh.. is it useful? im just sleepy. i think it's senseless.
minutes later....
darn it, there's quite a big difference here. using the hash thingy.
where alias c { hadd hasht item Hello } or alias c { return Hello }
c benchmark: 894 916 920 914 915 total: 4559 ave: 911.8
$c benchmark: 985 991 994 986 994 total: 4950 ave: 990
hadd hasht item $c benchmark: 1030 1035 1034 1021 1025 total: 5145 ave: 1029
where alias c hadd hasht item Hello (it's also a matter of alias c { statement } vs alias c statement)
benchmark: 880 901 865 880 894 total: 4420 ave: 884
comment:
to give you an idea here....
alias b {
var %a,%b,%c $1
%a = $ticks
while (%c) {
c
dec %c
}
%a = $ticks - %a
;echo . %b
return %a
}
alias c hadd hasht item Hello
does this mean that using an alias for adding items to a hashfile is faster? does it apply to other commands? is this real? am i awake? /me goes to bed. /me stands up, turns hd and monitor off. /me goes to bed.
$1- vs $1 $2-
$1- benchmark: 312 316 338 320 313 total: 1599 ave: 319.8
$1 $2- benchmark: 352 336 322 358 318 total: 1686 ave: 337.2
purpose:
alias switches or param.
comment:
tested using /c item there is no space available
where alias c hadd hasht $1- or $1 $2-
%b = $chan(0) while (%b) dec %b vs %b = 1 while ($chan(%b)) inc %b
dec %b benchmark: 139 136 148 138 146 total: 707 ave: 141.4
inc %b benchmark: 172 168 178 172 170 total: 860 ave: 172
purpose:
iterating through all channels
comments:
tested on 6 channels with atleast 10 characters using while (%b) inside while (%c) loop.
[return vs no return]
return benchmark: 1735 1844 1836 2035 2009 total: 9459 ave: 1891.8
no return benchmark: 2240 2229 2214 2500 2486 total: 11669 ave: 2333.8
purpose:
for example, a series if statements. the first or second if statement is true, return instead of waiting to reach the end of the code. i used this code:
alias c {
if ($1 = 1) { echo . 1 | return }
else if ($1 = 2) { echo . 2 | return }
else if ($1 = 3) { echo . 3 | return }
else if ($1 = 4) { echo . 4 | return }
else if ($1 = 5) { echo . 5 | return }
else if ($1 = 6) { echo . 6 }
else if ($1 = 7) { echo . 7 }
else if ($1 = 8) { echo . 8 }
else if ($1 = 9) { echo . 9 }
else if ($1 = 0) { echo . 0 }
else { echo . a }
}
and then in alias b, /c 1 inside the loop. got the idea? no return means you opt out "| return".
comments:
my point? in exchange for a bit larger script file size, including a return command for each if statement will speed it up, but only if the case was that there's no other code to execute below and if the earlier if statement is true. there's no point in including a return command in the last two if statements. if you don't get the logic... uhm... hmmm... let's say "else if ($1 = 2) { echo . 2 | return }" was true. after echoing ". 2", it returns right away. without it, mirc still goes through the code and to check if there are any more codes to execute. if you have more codes down there that needs not to be processed because one of the early statements are standalone, then include a return command.
|
|