The Rosetta smallpt project: the same path tracer (modifications of Kevin Baeson's 99 line C++ path tracer) written in multiple languages.
Note: I deliberately chose for the same software design for all programming languages out of clarity and performance reasons (this can conflict with the nature of declarative/functional programming languages).
Current languages:
- C
- single threaded
- multi threaded (OpenMP)
- C++
- single threaded
- multi threaded (Windows Threads)
- multi threaded (OpenMP)
- C#
- single threaded
- multi threaded
- CoffeeScript
- CUDA
- Erlang
- GLSL
- Haskell
- Java
- JavaScript
- J#
- Prolog
- Python 2
- Python 3
- Racket
- TypeScript
In order to give a very rough performance comparison, the wall clock time is measured of a single run to generate an image of resolution 1024x768 using 64spp. All single process - single threads experiments output the current progression to standard output. All multi process - multi threaded experiments do not output the current progression to standard output (this can change in the future).
System:
- OS: Windows 8.1 Pro 64 Bit
- CPU: Intel i7-4770K @ 3,50 GHz (TB @ 3,9 GHz) with 8GB DDR3 @ 1600 MHz
- GPU: NVIDIA GeForce GTX 970 with 4 GB GDDR5
Note: the random number generators used, differ between the languages and their implementations. It makes no sense to use the same random number generator in all implementations (i.e. C++ vs CUDA) and would introduce a huge burden to explicitly pass the state in languages such as Prolog.
Programming Language | Compiler/Interpreter | Wall clock (64 spp) |
---|---|---|
C | MSVC++ 15.5.9 | 00h 01m 51.88s |
C++ | MSVC++ 15.5.9 | 00h 01m 21.32s |
C# | CLR 4.6.1055.0 | 00h 01m 30.56s |
CoffeeScript | CC 1.11.1/Chrome | 00h 04m 19.63s |
Erlang | ERTS/BEAM 8.0 | 00h 59m 45.30s |
Haskell | GHC 8.0.1 | 00h 10m 35.55s |
Haskell | GHCi 8.0.1 | 02h 14m 54.00s |
Java | JVM 1.8 | 00h 01m 47.89s |
JavaScript | Chrome | 00h 06m 27.63s |
J# | CLR 14.00 | 00h 06m 14.62s |
Prolog | SWI-Prolog 7.2.3 | / |
Python 2.7 | CPython (Anaconda 4.1.12) | 08h 24m 40.88s |
Python 2.7 | CPython (Canopy 1.5.2) | 08h 35m 03.19s |
Python 2.7 | IronPython 2.7.6 | 06h 32m 11.48s |
Python 2.7 | PyPy 5.6.0 | 00h 20m 47.33s |
Python 3.5 | CPython (Anaconda 4.1.12) | 09h 37m 05.13s |
Python 2.7 + NumPy | CPython (Anaconda 4.1.12) | 09h 58m 25.18s |
Python 2.7 + NumPy | CPython (Canopy 1.5.2) | 10h 43m 04.10s |
Python 3.5 + NumPy | CPython (Anaconda 4.1.12) | 10h 20m 46.47s |
Racket | DrRacket 6.6 | 00h 49m 39.43s |
TypeScript | TSC 2.0.10/Chrome | 00h 08m 10.58s |
Programming Language | Compiler/Interpreter | Wall clock (64 spp) |
---|---|---|
C + OpenMP | MSVC++ 15.5.9 | 00h 00m 22.09s |
C++ | MSVC++ 15.5.9 | 00h 00m 16.71s |
C++ + OpenMP | MSVC++ 15.5.9 | 00h 00m 25.97s |
C# | CLR 4.6.1055.0 | 00h 00m 24.16s |
CUDA | MSVC++ 15.5.9/NVCC 9.2 | 00h 00m 07.89s |