The Computer Language
Benchmarks Game

Haskell GHC versus C gcc fastest programs

Back in April 2010, Russ Cox charitably suggested that only fannkuch-redux, fasta, k-nucleotide, mandlebrot, nbody, reverse-complement and spectral-norm were close to fair comparisons. As someone who implemented programming languages, his interest was "measuring the quality of the generated code when both compilers are presented with what amounts to the same program."

Differences in approach - to memory management, parallel programming, regex, arbitrary precision arithmetic, implementation technique - don't fit in that kind-of fair comparison — but we still have to deal with them.

These are only the fastest programs. There may be additional measurements for programs which seem more-like a fair comparison to you. Always look at the source code.

fasta
source secs mem gz busy cpu load
Haskell GHC 1.40 7,992 1882 4.15 75% 74% 75% 74%
C gcc 1.46 2,992 2268 5.81 99% 99% 99% 99%
regex-redux
source secs mem gz busy cpu load
Haskell GHC 1.78 307,992 2213 4.35 79% 50% 50% 65%
C gcc 1.48 152,188 1397 3.44 46% 45% 100% 41%
spectral-norm
source secs mem gz busy cpu load
Haskell GHC 4.10 4,012 987 15.83 97% 97% 99% 95%
C gcc 1.98 1,224 569 7.88 99% 99% 99% 100%
fannkuch-redux
source secs mem gz busy cpu load
Haskell GHC 18.37 4,352 842 72.54 96% 100% 100% 100%
C gcc 8.75 948 910 34.50 100% 100% 100% 95%
pidigits
source secs mem gz busy cpu load
Haskell GHC 4.22 9,964 585 5.27 8% 100% 9% 9%
C gcc 1.75 2,812 452 1.79 100% 0% 2% 1%
mandelbrot
source secs mem gz busy cpu load
Haskell GHC 4.87 36,328 1975 19.39 99% 100% 100% 99%
C gcc 1.64 26,504 1135 6.54 100% 100% 99% 100%
n-body
source secs mem gz busy cpu load
Haskell GHC 21.87 4,364 1883 86.49 99% 100% 99% 98%
C gcc 7.30 8 1391 7.37 0% 0% 100% 1%
reverse-complement
source secs mem gz busy cpu load
Haskell GHC 6.42 501,528 1020 9.38 14% 100% 16% 16%
C gcc 1.90 533,424 820 2.58 6% 20% 10% 99%
binary-trees
source secs mem gz busy cpu load
Haskell GHC 12.96 476,448 592 47.98 92% 92% 93% 94%
C gcc 3.53 168,844 809 11.76 98% 75% 86% 74%
k-nucleotide
source secs mem gz busy cpu load
Haskell GHC 35.91 637,624 1486 125.59 86% 86% 86% 91%
C gcc 6.00 130,132 1506 18.48 70% 95% 89% 53%
Haskell GHC

The Glorious Glasgow Haskell Compilation System,
version 8.8.1

C gcc

gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008