When you run that in the listener it uses the non optimizing compiler. You should use the EBNF: word [=[ ... ]=] form and then refer to word for it to be a compiled parser.
It’ll be much faster. Or wrap all that in a : foo ( — ) ... ; > On Nov 22, 2020, at 11:49 AM, Alexander Ilin <ajs...@yandex.ru> wrote: > > Hello! > > I've got my first test results, and I'm having some doubts. > > The following code runs almost 200 seconds on a 20Mb file: > > "file-name.csv" [ utf8 [ input-stream get > [ > EBNF[=[ > quotedColumn = "\""~ (!("\"") .)* "\""~ quotedColumn* > => [[ first2 swap prefix [ >string ] map "\"" join ]] > unquotedColumn = (!("\t") .)* > column = ( quotedColumn | unquotedColumn ) => [[ >string ]] > rule = column ( "\t"~ column )* => [[ first2 swap prefix ]] > ]=] , > ] each-stream-line > ] with-file-reader ] { } make > > > The following equivalent code using the csv vocab runs about 2 seconds on > the same file: > > "file-name.csv" [ utf8 [ input-stream get CHAR: \t [ > [ string>csv [ first , ] unless-empty ] each-stream-line > ] with-delimiter ] with-file-reader ] { } make > > > The difference is 100x, and the question is: is the speed difference related > to the fact that I'm running the code in the Listener? Could it be that if I > put it all into a vocab as opposed to running interactively it would get > better optimized and reach the performance of the csv vocab? > > ---=====--- > Александр > > > > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk