[antlr-interest] BENCHMARK. ANTLR. Bad results.

Braden McDaniel braden at endoframe.com
Fri Nov 12 16:20:48 PST 2004


Paul J. Lucas wrote:
> On Sat, 13 Nov 2004, Ruslan Zasukhin wrote:
> 
> 
>>Have you ever open the object of std::string In the debugger.
>>For different vendors this class have 2-3 levels of construction.
> 
> 
> 	And most of this is inlined.  When you single-step in a
> 	debugger, it goes to the original source line.  In reality,
> 	most of the construction is inlined and optimized away.
> 
> 
>>std::string class is very overloaded.
> 
> 
> 	I'm not sure what that means, exactly, but the size of the API
> 	has zero correlation to efficiency.
> 
> 
>>Let me answer that in our project we DO NOT use any STD classes,
>>Because we have prove they are not effective for our tasks... And because we
>>always can write own optimized for our task implementation.
> 
> 
> 	You do realize that std::string is actually a template and that
> 	you can plug-in your own underpinning while retaining the
> 	std::string API, right?

To a degree. You can't specialize std::basic_string for char or wchar_t, 
because those already exist (and are typedef'd as std::string and 
std::wstring, respectively). You can, of course, write your own class 
(or class template) with an API just like std::basic_string.

>>May be ANTLR in the _public_ API which we will use in our apps,
>>Should expose just char*. Then "problem" you point will go away.
>>If you like std::string in your app no problems
>>
>>    std::string str = antlr::foo_get_token()

Ruslan, so far you've provided no evidence that std::string is the 
problem. That's not to suggest that it's not; but I don't think you'll 
get much traction for such a change without reproducible data.

(And that is without raising the issue of whose std::string we're 
talking about.)

> 	And then the problem is right back again: if ANTLR used
> 	std::string internally (or any string) and it converts to char*
> 	and if you use some string class, your object ("str" above) has
> 	to construct itself -- performance hit.  Now if ANTLR returned
> 	std::string by reference and you did the assigment above, it's a
> 	simple pointer copy.

The typical std::string implementation is unlikely to be ideal from an 
efficiency perspective. That's not its role; its role is to be adequate. 
The performance characteristics required of a string class are 
sufficiently application specific that "one size fits most" is probably 
the best the C++ standard library will ever provide.

There's no question that ANTLR could provide a better one. The only 
question is whether std::string tends to be enough of a performance 
bottleneck to make it worth the effort.

Braden


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list