/count-primes

Count the number of primes - Programming Languages Benchmark

Primary LanguageFortranGNU General Public License v3.0GPL-3.0

count-primes

These benchmarks compare performance characteristics of different programming languages. In each language I implemented exactly the same algorithm that counts the number of primes between 0 and 20000000.

The results are:

Language Time (s)
C# 3.9
C 3.95
Intel Fortran 3.99
Delphi 4.25
C++ 4.3
gFortran 4.3
Java 4.6
Scala 4.7
JavaScript 5.7
F# 6.1
Julia 13.3
Go 13.4
FreePascal 14.3
Swift 14.8
Rust 19
Haskell 20.1
PHP 52.4
Ruby 64
Python 128
Lua 148
Perl 177
Tcl 214
R 402

Using Sieve of Eratosthenes:

Language Time (s)
Java 0.21
C# 0.39
Python 13.9