Thanks for the reply.
I use this matching way all over the place in the script, and until now, without any trouble or surprising performance loss, in a 900k script, this makewm alias is called from over 100 places in every script part.
IYour way requires a second alias for every alias that does such filter. And I have to pass parameters and return them using script-duration-set variables instead of alias parameters and return values.
That is quite unacceptable, I consider it very messy for little gain.
I tried that filter -fk way in the past, and regarding performance gain, the difference wasn't noticable and surely not worth above drawbacks.
In fact, in the past I used simply a while loop on all lines, a full tokenize (slow!) or some $gettok()'s (according to how many tokens to match) and actually, I started using /filter because it was faster in doing this
You did see my second wildcard test?
It contained the same amount (23) tokens
$makewm1(23,$+(1 *,$chr(215),4 ON,$chr(215),6 ON)) and it took 0.065 secs.
It doesn't make sense.
I ran another test, with only 3 (!!!) lines to filter:
alias testfilter {
var %w = @ChannelList1 | window %w | clear %w
aline -p %w Network1×#channel1×<NOKEY>×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×ON×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×DESCRIBE×OFF
aline -p %w Network2×#channel1×<NOKEY>×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×ON×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×DESCRIBE×OFF
aline -p %w Network3×#channel1×<NOKEY>×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×ON×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×OFF×DESCRIBE×OFF
window @TMP
var %i = 1 | while (%i <= 23) { testfilter2 $makewm1(23,%i OFF) | inc %i }
}
alias testfilter1 { var %ticks = $ticks | clear @TMP | filter -wwc @ChannelList1 @TMP $makewm1(23,$1 ON) | echo -s $1 $calc(($ticks - %ticks) / 1000) }
alias testfilter2 {
var %ticks = $ticks | clear @TMP
var %total1 = $line(@ChannelList1,0), %i1 = 1
while (%i1 <= %total1) {
var %rec = $line(@ChannelList1,%i1), %i2 = 1, %ok = 0
while (%i2 <= 23) {
if ($gettok($1-,%i2,215) iswm $gettok(%rec,%i2,215)) { inc %ok }
inc %i2
}
if (%ok == 23) { aline @TMP %rec }
inc %i1
}
echo -s $calc(($ticks - %ticks) / 1000)
}
alias makewm1 {
var %t = $chr(215), %a = $asc(%t), %total = $1, %toks = $2-
var %i = 1, %wm | while (%i < %total) { var %wm = $+(%wm,*,%t) | inc %i }
var %wm = $+(%wm,*), %total = $numtok(%toks,%a), %i = 1 | while (%i <= %total) { tokenize 32 $gettok(%toks,%i,%a) | var %wm = $puttok(%wm,$2-,$1,%a) | inc %i }
return %wm
}
The testfilter alias now has a while loop that shifts up one token to match (22/23 are just a * wildcard) from position 1 to position 23, and calls everytime the testfilter1 or testfilter2 aliases.
I wrote alias testfilter so that it has to check all of the 23 token positions, to mimic filter in some degree.
These are the results:
tesffilter1:testfilter2
1 0.005 : 0.01
2 0.01 : 0.01
3 0.045 : 0.01
4 0.182 : 0.009
5 0.474 : 0.01
6 0.884 : 0.01
7 1.215 : 0.015
8 1.54 : 0.01
9 2.12 : 0.01
10 3.425 : 0.01
11 5.415 : 0.01
12 0.005 : 0.01
13 10.285 : 0.009
14 12.29 : 0.01
15 13.645 : 0.015
16 14.436 : 0.01
17 14.86 : 0.01
18 15.02 : 0.01
19 15.056 : 0.01
20 15.065 : 0.01
21 15.079 : 0.009
22 15.09 : 0.01
23 15.08 : 0.01
You see what happens? Filter is as speedy as the scripted way for the first two tokens and then becomes thousands times slower, there is a weird exception somewhere around the middle position, where it is suddenly back as fast as the scripted one..
The conclusion is simple:
A full scripted loop is 1000's times faster than /filter except from the first two onwards and the middlest token.
Remember this is about 3 lines to filter on one position?
15 seconds?
Matching ONE line of a @custom window needs 5 full seconds.
A SINGLE string, that is.
So I'll just abandon using filter for this. For some reason, its extremely bad for this.