Phil Dawes wrote: > Hi Slava, > > [ ... ] > Which when compiled with -O3 takes about 80ms to search the file on a > processor locked at 800MHZ with the filebuffers running warm. The best I > could do with factor in this setup was a few seconds (which I think is > still pretty good). >
Incidentally, here is the best performing 'count-items' I could do in factor, which was basically to modify 'each' to jump 4 bytes at a time. This was ~70% faster than using the builtin factor 'count' and using '4 fixnum*fast' each iteration to generate the addresses. It clocks in at ~1400ms on the same setup as the asm test (see orig email). Any tricks I'm missing? -Phil : next+4 ( from to quot -- from' to quot ) [ 4 fixnum+fast ] 2dip ; inline : (each-elem-int) ( from to quot: ( i -- ) -- ) [ iterate-step next+4 (each-elem-int) ] [ 3drop ] if-iterate? ; inline recursive : each-step-4 ( to quot -- ) 0 -rot (each-elem-int) ; inline : each-uint ( alien size quot -- ) [ alien-unsigned-4 ] prepose with each-step-4 ; inline : each-uint* ( mmap quot -- ) [ [ address>> ] [ length>> ] bi ] dip each-uint ; inline : myreduce ( mmap identity quot -- result ) swapd each-uint* ; inline : mysigma ( mmap quot -- n ) [ + ] compose 0 swap myreduce ; inline : mycount ( mmap quot -- n ) [ 1 0 ? ] compose mysigma ; inline : count-items ( mmap item -- n ) [ = ] curry mycount ; inline : with-whole-mapped-file ( fname quot -- ) [ dup file-info size>> ] dip with-mapped-file ; inline : test-count-items ( fname val -- count ) [ count-items ] curry with-whole-mapped-file ; ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
