Coder Social home page Coder Social logo

edin / raytracer Goto Github PK

View Code? Open in Web Editor NEW
57.0 57.0 22.0 9.43 MB

Performance comparison of various compilers

License: MIT License

PHP 5.85% Java 5.47% Batchfile 0.51% Python 3.12% Pascal 5.45% C++ 4.41% C# 13.10% Ruby 3.60% D 4.44% Go 3.79% C 5.44% Fortran 5.86% Nim 3.71% Rust 4.81% Swift 8.21% TypeScript 4.65% Zig 5.11% Visual Basic .NET 5.12% F# 3.97% Julia 3.38%

raytracer's People

Contributors

darleybarreto avatar edin avatar elvisoric avatar gabriellasso avatar jzakiya avatar lmiq avatar mgrojo avatar paulsmithkc avatar shirleyquirk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raytracer's Issues

Add Kotlin

Both Kotlin/JVM and Kotlin/Native would be nice :)

Python is unfarily short because it uses PIL library.

Python appears to be the only language to use external library PIL to write the bitmap out. This makes it significantly shorter then other languages.

I think to be fair to other languages in the lines of code benchmark Python should not use PIL and write the .bmp like the other languages.

Nim's implantation has double empty lines and comments other languages do not have. If Python is forced to write out the bitmap and Nim's code is cleaned up I think Nim might be able to take the top spot in both speed and shortness.

D

Hi! Interesting benchmarks ๐Ÿ‘

But I see you are using some deprecated switches for D.

For example "noboundscheck" should be "boundscheck=off".

You're also using a lot of classes instead of structs (compared to the C++ version). If you don't want (don't have time) to change it to structs, consider adding the final keyword before class to make the comparison a bit fairer (vtable) :)

Thanks!

Revised Rust version not using function test_ray

In going over the revised Rust version from a couple of days ago, the compiler says test_ray function not used, though the image does not appear affected because of it.

    fn test_ray(&self, ray: &Ray) -> Option<f32>
    {
        let intersect = self.intersections(ray);
        return match intersect {
            Some(result) => Some(result.dist),
            None => None
        }
    }

In the Ruby, Crystal, et al version it was used in

  def addLight(col, light, pos, norm, scene, thing, rd)
    ldis  = Vector.minus(light.pos, pos)
    livec = Vector.norm(ldis)
    neatIsect = self.testRay(Ray.new(pos, livec), scene)
   ...
 end

In Nim as

func getNaturalColor(scene: Scene, sp: SurfaceProperties,
  pos, rd, norm: Vector): Color =
  var rdNorm = rd.norm()
  for light in scene.lights:
    let
      ldis = light.pos - pos
      ldisLen = ldis.len()
      livec = ldis.norm()
      neatIsect = scene.testRay(pos, livec)
      ...

Add JRuby

It might be nice to include JRuby, since we appear to be faster than all recent CRuby versions.

On my system (using OpenJDK 11):

[] ~/projects/raytracer/ruby $ rvm ruby-2.7.0 do ruby RayTracer.rb 
Completed in 20886.185999999998 ms

[] ~/projects/raytracer/ruby $ rvm ruby-3.0.2 do ruby RayTracer.rb 
Completed in 16813.604000000003 ms

[] ~/projects/raytracer/ruby $ rvm jruby-9.3.0.0 do ruby RayTracer.rb 
Ignoring executable-hooks-1.6.1 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.1
Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0
Completed in 13248.208 ms

[] ~/projects/raytracer/ruby $ rvm jruby-9.3.0.0 do ruby -Xcompile.invokedynamic RayTracer.rb 
Ignoring executable-hooks-1.6.1 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.1
Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0
Completed in 7894.947999999999 ms

If this scales the same way on your end it would put the JRuby results somewhere between HHVM and PHP, which I'd like to see. ๐Ÿ˜€

Fortran version won't build

I'm trying to build the Fortran version and have run into some problems.

raytracer> gfortran --version
GNU Fortran (PCLinuxOS 10.3.0-1pclos2021) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When I use the build instructions I get this error.

raytracer> gfortran.exe main.f95 -O3 -o FRay.exe
zsh: command not found: gfortran.exe

When I ran it without the .exe it gives a missing library error.

raytracer> gfortran main.f95 -O3 -o FRay.exe 
/usr/bin/ld: cannot find -lquadmath
collect2: error: ld returned 1 exit status

Add results for all languages

These languages don't have results:
Zig
V
Swift
Haskel
Ada

I'm interested in the Ada version. It's easy to test in Ubuntu/Debian. Install packages gprbuild and gnat-12 and run gprbuild -p raytracer.gpr.

Upgrading Ruby version

I see a number of the language versions have been upgraded.
I've done an optimized version of the original Ruby implementation that mimics Crystal.
How should I submit the new Ruby code to you?

Update LOC for versions

Thank you for updating some of the timings.

When you have time, can you also update the LOCs too.

C produces no viewable image, Rust produces a different image from all others.

When I ran the C code version, it produces a bad *.bmp file of 1,000,102 bytes, which doesn't show an image.
Also, while the Rust code produces a viewable image, the image has different shading from all the others.

Here are comparisons with other *.bmp files that produce correct viewable images.

โžœ  raytracer ls -al *bmp
-rw-rw-r-- 1 jzakiya jzakiya 1000054 Apr 10 01:28 cpp-raytracer.bmp
-rw-rw-r-- 1 jzakiya jzakiya 1000102 Apr 10 01:28 c-raytracer.bmp
-rw-rw-r-- 1 jzakiya jzakiya 1000054 Apr 10 01:27 d-raytracer.bmp
-rw-rw-r-- 1 jzakiya jzakiya 1000054 Mar 25 11:59 julia-ray.bmp
-rw-rw-r-- 1 jzakiya jzakiya 1000054 Mar 24 17:04 nim-raytracer.bmp
-rw-rw-r-- 1 jzakiya jzakiya 1000054 Apr 10 01:28 nim-RayTracer.bmp
-rw-rw-r-- 1 jzakiya jzakiya  750054 Mar 15 12:43 ruby-raytracer-266.bmp
-rw-rw-r-- 1 jzakiya jzakiya  750054 Mar 15 12:35 ruby-raytracer-272.bmp
-rw-rw-r-- 1 jzakiya jzakiya  750054 Mar 15 12:51 ruby-raytracer-jruby9.2.16.0.bmp
-rw-rw-r-- 1 jzakiya jzakiya  750054 Mar 24 16:54 rust-raytracer.bmp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.