I agree about the theory and with what you said about $read and filter
Multiple $reads could potentially be faster if the matches are found near the start of the file, as it will have less data to go through than /filter.
I made another test to check that :
%n is the number of match we want from the start of the
file (just some copy/paste of the previous file) :
alias benchread1 {
var %t $ticks ,%a 1000
while (%a) {
var %l 1,%n 2
while ($read(test.txt, wn, *}}}}}}}}}}*,%l) != $null) && (%n) { noop match the file on line $readn : $v1 | %l = $readn + 1 | dec %n }
dec %a
}
echo -a in $calc($ticks - %t) ms
}
alias _test if (%n) noop match the file on line $1 : $2- | dec %n
alias benchread2 {
var %t $ticks,%a 1000
while (%a) {
set -u %n 2
filter -fnk test.txt _test *}}}}}}}}}}*
dec %a
}
echo -a in $calc($ticks - %t) ms
}
Using this file, /filter is slower than $read for %n <= 4 in my test
In any event, was just offering another alternative
Yeah, it's fine, but the purpose of my post was to compare two methods involving $read, not to do the job the fastest ways possible