473,387 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

a question about efficiency of STL

Expand|Select|Wrap|Line Numbers
  1. #include <list>
  2.  
  3. int main()
  4. {
  5.         std::list<int> lst;
  6.         for(int i=0; i<1000; i++)
  7.         {
  8.                 for(int x=0; x<5000; x++)
  9.                         lst.push_back(x);
  10.                 lst.clear();
  11.         }
  12.         return 0;
  13. }
I compiled this code on VC8 (Release version ) and Cygwin G++ 3.4.4 and compare the result :

$time test_gcc
real 0m13.100s
user 0m13.077s
sys 0m0.031s

$time test_vc
real 0m3.552s
user 0m0.031s
sys 0m0.015s

why the difference is so far?
Apr 10 '08 #1
3 1251
gpraghuram
1,275 Expert 1GB
Every compiler implements the STL in a different way.
But i am also surrised to see this much difference

Raghuram
Apr 10 '08 #2
Banfa
9,065 Expert Mod 8TB
This doesn't even have to be an STL issue, it could simply be a compiler/optomiser issue.

For instance did you put switches on both compilers to optimise the output exe for time exectution or did you optimise one for time and the other for size?

For a long while gcc was lagging in producing efficent code to run on Windows (although I thought they had more or less caught up now) and in fact I believe the best compiler you can get for an Intel based PC is the Intel compiler (not too unsurprisingly they understand best how to optimise code to run on their chips).

The thing is that the way gcc and GNU compilers in general work is to cross compile to an intermediary code (p code?) and then compile that p code into a platform specific exe. This makes it very easy to add a new platform supported by many languages or add a new language to many platforms but the method is generic and because of that it is inherently hard for it to compete on efficiency with a targeted method. That is a compiler targeted at 1 platform and 1 language.

Like I said I thought the gcc developers had done something clever to get round this to some extent on the later releases so I would try fiddling with the compiler switches as a start.
Apr 10 '08 #3
weaknessforcats
9,208 Expert Mod 8TB
Whose STL is being used?

Visual C++ uses Plaugher's templates at Dinkumware.com. These are optimized for speed.
Apr 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Steve M | last post by:
1. Near the beginning of the document "Unifying types and classes in Python 2.2" by GvR, which can be found at http://www.python.org/2.2.2/descrintro.html, the author writes the following about...
1
by: Laser Lu | last post by:
Whether it can improve the execution effciency of ASP by centeralizing the often used code into header files and then including these header files in ASP pages? -- Best regards, Laser Lu
10
by: Scotter | last post by:
Please forgive me for reposting; last title didn't quite say it right. I have an ASP application I wrote in vbScript so this is not .Net. There are 20 nearly identical versions of this...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
2
by: zhege | last post by:
I am a beginner of C++; I have a question about the std:string and std:cout class; Two pieces of code: -------------------------------- #include <iostream> #include <string> using namespace...
335
by: extrudedaluminiu | last post by:
Hi, Is there any group in the manner of the C++ Boost group that works on the evolution of the C language? Or is there any group that performs an equivalent function? Thanks, -vs
2
by: yicong | last post by:
hi,All could you tell me which case is more efficiency?(my tables have no index) And does it has any else case more efficiency? case1: "select sum(Invoice_Production.Quantity) from...
23
by: TefJlives | last post by:
Hi all, I'm learning a bit about C, and I have a few questions. I'm not trying to insult C or anything with these questions, they're just honestly things I don't get. It seems like pointers...
9
by: OldBirdman | last post by:
Efficiency I've never stumbled on any discussion of efficiency of various methods of coding, although I have found posts on various forums where individuals were concerned with efficiency. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.