STL Alternative

前端 未结 15 1817
故里飘歌
故里飘歌 2021-01-31 04:24

I really hate using STL containers because they make the debug version of my code run really slowly. What do other people use instead of STL that has reasonable performance for

相关标签:
15条回答
  • 2021-01-31 04:56

    There is also the ETL https://www.etlcpp.com/. This library aims especially for time critical (deterministic) applications

    From the webpage:

    The ETL is not designed to completely replace the STL, but complement it. Its design objective covers four main areas.

    • Create a set of containers where the size or maximum size is determined at compile time. These containers should be largely equivalent to those supplied in the STL, with a compatible API.
    • Be compatible with C++ 03 but implement as many of the C++ 11 additions as possible.
    • Have deterministic behaviour.
    • Add other useful components that are not present in the standard library.

    The embedded template library has been designed for lower resource embedded applications. It defines a set of containers, algorithms and utilities, some of which emulate parts of the STL. There is no dynamic memory allocation. The library makes no use of the heap. All of the containers (apart from intrusive types) have a fixed capacity allowing all memory allocation to be determined at compile time. The library is intended for any compiler that supports C++03.

    0 讨论(0)
  • 2021-01-31 05:00

    EASTL is a possibility, but still not perfect. Paul Pedriana of Electronic Arts did an investigation of various STL implementations with respect to performance in game applications the summary of which is found here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html

    Some of these adjustments to are being reviewed for inclusion in the C++ standard.

    And note, even EASTL doesn't optimize for the non-optimized case. I had an excel file w/ some timing a while back but I think I've lost it, but for access it was something like:

           debug   release
    STL      100        10
    EASTL     10         3
    array[i]   3         1
    

    The most success I've had was rolling my own containers. You can get those down to near array[x] performance.

    0 讨论(0)
  • 2021-01-31 05:00

    Qt has reimplemented most c++ standard library stuff with different interfaces. It looks pretty good, but it can be expensive for the commercially licensed version.

    Edit: Qt has since been released under LGPL, which usually makes it possible to use it in commercial product without bying the commercial version (which also still exists).

    0 讨论(0)
提交回复
热议问题