Home

OFF-SOFT.net

OFF-SOFT.net

This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]

GCC vs VC++ (optimization)

Published on| September 22nd, 2009 | No Comment.
Summary:
Well on Windows, GCC and VC + + compilers are compared.
Personal opinion is any better compiler, you use either, and I feel like the taste of the developer.

This is a dare, on this question, decorated the optimization program is run so that one reference, I have a simple sample program to check how much sooner.

Now that you mentioned is actually my PC (WindowsXP) and described the results of our run. However, that sample is just one example, please advance our understanding.

Sample source code
Before trial, we created a simple test using a sample program Resona.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <ctime>
 
using namespace std;
 
int main(int argc, char *argv[])
{
	int ni;
	int nmax = 10000000;
	double d1,d2,d3;
	{
		//	timer
		std::clock_t _start_time = std::clock();
 
		d2=4;d3=1.001;
		for(ni=0;ni<nmax;ni++){
			d1=d2*d3;
			d2=d1;
			if((ni%10)==0){
				d1=d2/1.01001;
                d2=d1;
			}
		}
 
		d1 = (double(std::clock() - _start_time) / (double)CLOCKS_PER_SEC);
		cout << d1 << "(s)" << endl;
		cout << "(val)" << d2 << endl;
		cout << "(count)" << ni << endl;
	}
 
	return 0;
}

This is a very simple example. Multiplication, remainder, only the computation of the division is 10,000,000 times.
However, this final answer, underflow, and to prevent overflow.
This calculation results, 5.04832e +015 is.
This, GCC 3.4.5, GCC 4.4.0, VC + +7.1 (2003), VC + +9 (2008) to compile.
Runtime library, DLL, and supports multi-threading, optimization, O2 has set the options.

Results
Compiler Processing time (seconds)
GCC 3.4.5 0.171
GCC 4.4.0 0.234
VC7.1 0.171
VC9 0.062

These results now.

This result might be coincidence, GCC 3.4.5 and GCC 4.4.0 from a slow process that is interesting.
Addition, VC7.1 (VC + + Tookit 2003) and the optimization of GCC 3.4.5, and I did not change is the most interesting.

For reference, the size, VC7.1 the case, most were smaller.
※サイズに関しては、GCCは、非常に不利ですので、ここでは、あえて記述を避けています。

Strictly the result of the above sample program.
Other programs, I sometimes get different results. In fact, that the various sites, GCC also a good article the results of the second well.

Purposes only, thank you to the reference level.
However, this result is Hopefully something helpful.


Comments

Leave a Reply







  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ