|  | How to stl library efficiently? |  | |
| | | Peng Yu |  |
| Posted: Sun Aug 10, 2008 5:49 am Post subject: How to stl library efficiently? |  |
Hi,
I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
Thanks, Peng
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Ulrich Eckhardt |  |
| Posted: Sun Aug 10, 2008 4:03 pm Post subject: Re: How to stl library efficiently? |  |
Peng Yu wrote:
| Quote: | I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
|
There is also deque as possible unordered container. BTW, can you supply a URL of mentioned discussion?
| Quote: | I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
|
It's a very obvious trick but it still applies here: profile first, optimise later.
Lastly: the STL was in large parts incorporated into the C++ stardardlibrary but the overlap is not 100%. I'd generally target my code at the C++ standardlibrary, the STL itself is pretty much dead nowadays.
Uli
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | red floyd |  |
| Posted: Sun Aug 10, 2008 4:28 pm Post subject: Re: How to stl library efficiently? |  |
Peng Yu wrote:
| Quote: | Hi,
I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
|
Get Scott Meyer's "Effective STL".
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Mathias Gaunard |  |
| Posted: Sun Aug 10, 2008 4:28 pm Post subject: Re: How to stl library efficiently? |  |
On 10 août, 07:49, Peng Yu <PengYu...@gmail.com> wrote:
| Quote: | I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
|
You need move semantics and in-place construction for comparable performance. Which are not in the current implementation.
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Sergey P. Derevyago |  |
| Posted: Wed Aug 13, 2008 6:24 pm Post subject: Re: How to stl library efficiently? |  |
| |  | |
Peng Yu wrote:
| Quote: | I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
Sure. |
Please read "C++ multithreading: mem_pool" message: Message-ID: <4899c3e1$0$90276$14726298@news.sunsite.dk> LINK
-----------------------------------8<----------------------------------- void start_std(void*) { list<int> lst; for (int i=0; i<N; i++) { for (int j=0; j<M; j++) lst.push_back(j); for (int j=0; j<M; j++) lst.pop_front(); } } void start_ders(void*) { mem_pool mp; stl_allocator<int> alloc(mp);
list<int, stl_allocator<int> > lst(alloc); for (int i=0; i<N; i++) { for (int j=0; j<M; j++) lst.push_back(j); for (int j=0; j<M; j++) lst.pop_front(); } } -----------------------------------8<----------------------------------- The table at LINK shows that start_ders() function is tens and hundreds (!!!) of times faster: 1 CPU : 38.1 1 CPU,HT : 42.1 2 CPU,SMP: 321.6 (!!!) 2 CPU,HT : 37.0 -- With all respect, Sergey. LINK mailto : ders at skeptik.net
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Peng Yu |  |
| Posted: Sun Aug 17, 2008 6:51 pm Post subject: Re: How to stl library efficiently? |  |
| Quote: | The table LINK that start_ders() function is tens and hundreds (!!!) of times faster:
|
The website you mentioned in some language rather than English (maybe Russian). I don't understand that language. Is there an English version for it.
Thanks, Peng
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Peng Yu |  |
| Posted: Sun Aug 17, 2008 6:52 pm Post subject: Re: How to stl library efficiently? |  |
| |  | |
On Aug 10, 11:03 am, Ulrich Eckhardt <dooms...@knuut.de> wrote:
| Quote: | Peng Yu wrote: I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
There is also deque as possible unordered container. BTW, can you supply a URL of mentioned discussion?
|
I came across such webpage long time back. I can recall where it is. Sorry about that.
| Quote: | I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
It's a very obvious trick but it still applies here: profile first, optimise later.
Lastly: the STL was in large parts incorporated into the C++ stardardlibrary but the overlap is not 100%. I'd generally target my code at the C++ standardlibrary, the STL itself is pretty much dead nowadays.
|
I always use the following website for the documentation when I use STL. LINK
Where is the C++ Standard Library manual? I found this one LINK Is it appropriate?
What is the major difference between C++ Standard Library and STL? I usually use GCC C++ compiler. It has the complete C++ Standard Library, right?
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Peng Yu |  |
| Posted: Sun Aug 17, 2008 6:52 pm Post subject: Re: How to stl library efficiently? |  |
On Aug 10, 11:28 am, red floyd <no.spam.h...@example.com> wrote:
| Quote: | Peng Yu wrote: Hi,
I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
Get Scott Meyer's "Effective STL".
|
It seems that it is a little bit outdated. For example, it mentioned auto_ptr, but people usually use boost::shared_ptr. I'm wondering what are the things that have been changed since the book was written.
Thanks, Peng
-- [ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Erik Wikström |  |
| Posted: Mon Aug 18, 2008 1:58 pm Post subject: Re: How to stl library efficiently? |  |
| |  | |
On 2008-08-17 20:52, Peng Yu wrote:
| Quote: | On Aug 10, 11:03 am, Ulrich Eckhardt <dooms...@knuut.de> wrote: Peng Yu wrote: I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
There is also deque as possible unordered container. BTW, can you supply a URL of mentioned discussion?
I came across such webpage long time back. I can recall where it is. Sorry about that.
I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
It's a very obvious trick but it still applies here: profile first, optimise later.
Lastly: the STL was in large parts incorporated into the C++ stardardlibrary but the overlap is not 100%. I'd generally target my code at the C++ standardlibrary, the STL itself is pretty much dead nowadays.
I always use the following website for the documentation when I use STL. LINK
Where is the C++ Standard Library manual? I found this one LINK Is it appropriate?
What is the major difference between C++ Standard Library and STL? I usually use GCC C++ compiler. It has the complete C++ Standard Library, right?
|
STL is the name that was used before it became part of the C++ standard, the C++ standard library contains the STL and some other stuff (like IO capabilities etc.), so you can say that the STL is a subset of the standard library.
The gcc standard library implementation is probably close to complete, you can probably find detailed information about its conformance at the gnu site.
-- Erik Wikström
[ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| | | Erik Wikström |  |
| Posted: Mon Aug 18, 2008 8:55 pm Post subject: Re: How to stl library efficiently? |  |
| |  | |
On 2008-08-17 20:52, Peng Yu wrote:
| Quote: | On Aug 10, 11:28 am, red floyd <no.spam.h...@example.com> wrote: Peng Yu wrote: Hi,
I came across some discussion on that improper usage stl library could make program performance bad. Some tips are trivial, such as using the appropriate algorithm, choosing the best data structure (say, vector vs. list).
I'm wondering whether are less obvious tricks to make stl based program performance as good as the hard coded C program?
Get Scott Meyer's "Effective STL".
It seems that it is a little bit outdated. For example, it mentioned auto_ptr, but people usually use boost::shared_ptr. I'm wondering what are the things that have been changed since the book was written.
|
Nothing, the C++ standard has not been update since then. On the other hand a number of new libraries have been developed and evolved since then (such as boost), but none of them are part of the C++ standard. Work on the next version of the C++ standard is ongoing the new version (which contains something like boost::shared_ptr, and much more) will hopefully be out in 2009, but it will take a while longer until compilers and libraries support the new stuff.
-- Erik Wikström
[ See LINK for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |
| |
| Page 1 of 3 .:. Goto page 1, 2, 3 Next | |
|
|