help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C versus C++ parser performance


From: David Fang
Subject: Re: C versus C++ parser performance
Date: Fri, 16 Feb 2007 01:10:04 -0500 (EST)

> >>> "GDA" == Geoffrey D Alexander <address@hidden> writes:
>
>  > However, I did notice a slowdown of 5 to 20 percent in the C++ parser.
>  > Also, the C++ parser shows an increase of 10 to 15 percent in the number
>  > of memory allocation as reported by valgrind.
>
>  > Is this a known problem?  Are there plan to improve C++ parser
>  > performance?
>
> Yes, it is known: for various reasons (such as avoiding to copy the
> content of the stack) we implemented the stack on top of a std::deque.
> Of course I'd like to use something more efficient, say std::vector.
> At the same time, I'd like to implement something similar to a weak
> form of variants that would allow use to include objects too, not just
> PODs on the stack.
>
> In the meanwhile, if you're interested in helping, it shouldn't be too
> difficult to just keep the limitations, but use a std::vector.

Hi all,
        Another tip regarding performance of STL containers: containers
such as list/vector have an additional template parameter that defaults to
std::allocator.  Often times, by passing in a customized allocator (e.g.
pool-allocator) to the container type, you can get significant speedup.
Also, std::vector has a useful reserve() member function that allows you
to pre-allocate memory, which can reduce expensive reallocations as a
result of push_back().

HTH,

Fang

David Fang
Computer Systems Laboratory
Electrical & Computer Engineering
Cornell University
http://www.csl.cornell.edu/~fang/
        -- (2400 baud? Netscape 3.0?? lynx??? No problem!)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]