About

June 18, 2026 ยท View on GitHub

Raytracer benchmarks based on Typescript sample.

Workflow

Use the root ray wrapper as the default way to build, run, compare, and benchmark samples. Per-language run.bat and run.sh scripts are intentionally not used; commands live in projects.xml so the same workflow can run locally and later inside Docker.

dotnet build tools\Tools.csproj
ray time csharp --width 500 --height 500
ray time zig --width 500 --height 500 --format json
ray imagediff csharp zig

Results

Language / CompilerTime [ms]
Nim130 ms
C++ (GCC)160 ms
Fortran160 ms
C (GCC)160 ms
Crystal190 ms
D (LDC)210 ms
Rust220 ms
C (MSVC)250 ms
C++ (MSVC)250 ms
VB.NET360 ms
C#360 ms
Delphi XE6390 ms
Odin450 ms
Go460 ms
D (DMD)500 ms
Java 8-14600 ms
Delphi 2010 (32 bit)720 ms
Node 15 (JS)734 ms
Julia783 ms
Scala820 ms
Node 15 (TS)1100 ms
F#1800 ms
Node 81800 ms
PHP (PHP 8.0)7450 ms
HHVM11000 ms
PHP (PHP 7.4)24500 ms
PHP (PHP 7.3)23500 ms
PHP (PHP 7.0)25500 ms
Ruby 2.637600 ms
Ruby 2.247800 ms
Python 3.761000 ms
Python 3.568000 ms
PHP (PHP 5.6)83000 ms
Zig? ms
V? ms
Swift? ms
Haskel? ms
Ada? ms

Lines of code

LanguageLoc
Python275
F#300
Ruby351
Julia360
Nim379
Typescript412
C#426
Swift450
C++461
VB.NET481
D490
PHP491
Go529
C560
Fortran565
Java569
Delphi678

Comments:

C - Simple, clean, and fast

C++ - Unlike C, C++ version does bounds checking, otherwise, performances are mostly the same

Nim - Uses Quake square root algorithm

Delphi2010 - Uses old 32 bit compiler

Node/V8 - Node is fast

F# - This should be close to C# and VB.Net, but I don't have much experience with F#

Tested On

Tested on AMD FX-8120 Cpu.