Re: Qi Symbols parser performance

Joel de Guzman <[email protected]> Sat, 13 Jan 2018 08:43:08 +0800
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 13/01/2018 12:22 AM, Stephan Menzel wrote:
> Hello Joel,
> 
> thanks for your response!
> 
> On Fri, Jan 12, 2018 at 4:49 PM, Joel de Guzman <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>     1) Why use grammars and rules? Those are unnecessary. You can use
>         symbols directly.
> 
> 
> Well, yes, I know. I have been using spirit for so many years, that's just the way I use 
> it because that was how I learned it back then. I suppose that wouldn't explain a 
> difference of this magnitude though. I will still test this without the grammar to rule 
> out overhead brought in this way.
> 
>     2) Symbols use ternary search tries: http://tinyurl.com/ydy3fnnp
>     3) They might not be the best choice for your use case. They are best
>         used for parsing languages, especially when you expect lots of partial
>         matches and misses (e.g. keywords in a language, where you expect other
>         lexemes apart from just keywords.
> 
> 
> The way I understand that order is not that different from how an rb-tree would order a 
> map now, is it? Which is why I brought this up. No matter how bad a choice the used 
> datastructure would be, shouldn't it still _not_ be outperformed by a blank unordered list 
> of strings which are compared one after the other, doing the lowercasing each time?

If there's something suspicious, then there probably is, and more often it's
the usage (although sometimes, there are indeed issues with the library). I
hinted about the use of rules and grammars, and Seth later pointed that you
creating rules and grammars inside the loop, which is never good. Parsers
are supposed to be created only once and used (to parse) many times.

Again, thank you Seth for looking into this issue. What Seth presented is what
I'd consider as best practice.

Regards,
-- 
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general