1 : At a glance - Are the C++ g++ programs faster?

Each chart bar shows, for one unidentified benchmark, how much the fastest C++ g++ program used compared to the fastest C gcc program.

(Memory use is only compared for tasks that require memory to be allocated.)


These are not the only compilers and interpreters. These are not the only programs that could be written. These are not the only tasks that could be solved. These are just 10 tiny examples.

 2 : Approximately - Are the C++ g++ programs faster?

Each table row shows, for one named benchmark, how much the fastest C++ g++ program used compared to the fastest C gcc program.

(Memory use is only compared for tasks that require memory to be allocated.)

 C++ g++ used what fraction? used how many times more? 
Benchmark Time Memory Code
 k-nucleotide1/2±±
 n-body± ±
 spectral-norm± 
 mandelbrot± ±
 pidigits± 
 fannkuch-redux± 
 reverse-complement±±
 fasta-redux± ±
 regex-dna1/21/4
 binary-trees±
 fasta † 1/2
 C++ g++ used what fraction? used how many times more? 
Time-used  |-  |---  25% median  75%  ---|  -|
(Elapsed secs)1/21/2±±±

† possible mismatch - one-core program compared to multi-core program.

± read the measurements and then read the program source code.

 3 : Measurements - Are the C++ g++ programs faster?

These are not the only tasks that could be solved. These are just 10 tiny examples. These are not the only compilers and interpreters. These are not the only programs that could be written.

For each named benchmark, measurements of the fastest C++ g++ program are shown for comparison against measurements of the fastest C gcc program.

Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
 k-nucleotide 
C++ g++23.607.22132,7401252  78% 77% 76% 98%
C gcc36.5812.35131,9041535  37% 71% 95% 94%
 n-body 
C++ g++9.129.138761545  0% 0% 100% 1%
C gcc10.3810.397361490  0% 100% 1% 1%
 spectral-norm 
C++ g++7.962.002,0241044  100% 100% 100% 100%
C gcc7.861.981,704569  99% 100% 99% 99%
 mandelbrot 
C++ g++22.975.7733,5921017  99% 99% 99% 100%
C gcc22.405.6128,988799  100% 100% 100% 100%
 pidigits 
C++ g++2.682.693,076682  0% 1% 2% 100%
C gcc2.492.502,140448  100% 0% 1% 0%
 fannkuch-redux 
C++ g++50.9313.021,4121440  100% 94% 99% 100%
C gcc39.4910.061,388910  99% 99% 95% 100%
 reverse-complement 
C++ g++1.170.78247,3402275  23% 87% 11% 47%
C gcc0.860.60251,368741  95% 84% 44% 15%
 fasta-redux 
C++ g++2.102.101,1201474  100% 0% 0% 1%
C gcc1.591.596241402  100% 1% 1% 0%
 regex-dna 
C++ g++5.574.02176,492695  2% 63% 75% 1%
C gcc6.342.67290,7922579  96% 76% 84% 67%
 binary-trees 
C++ g++16.575.08180,752892  81% 85% 82% 83%
C gcc9.682.97105,024906  93% 77% 87% 72%
 fasta 
C++ g++4.284.281,1681105  1% 1% 1% 100% †
C gcc5.291.812,3521914  89% 53% 54% 100% †

† possible mismatch - one-core program compared to multi-core program.

 4 : Are there other C++ g++ programs for these benchmarks?

Remember - those are just the fastest C++ g++ and C gcc programs measured on this OS/machine. Check if there are other implementations of these benchmark programs for C++ g++.

Maybe one of those other C++ g++ programs is fastest on a different OS/machine.

 5 : Are there other faster programs for these benchmarks?

Remember - those are just the fastest C++ g++ and C gcc programs measured on this OS/machine. Check if there are faster implementations of these benchmark programs for other programming languages.

Maybe one of those other programs is fastest on a different OS/machine.

 C++ g++ : c plus objects plus generics 

C++ 1991-2006, Bjarne Stroustrup (pdf)

Online book: Looking for 4x speedups? SSE to the rescue! pdf slides

gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13)

Home Page: http://gcc.gnu.org/

Download: ftp://ftp.gnu.org/pub/gnu/gcc/

Revised BSD license

  Home   Conclusions   License   Play