GithubHelp home page GithubHelp logo

indyjo / rays Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kidoman/rays

0.0 2.0 0.0 347 KB

Ray tracing based language benchmarks

Home Page: https://kidoman.com/programming/go-getter.html

C++ 14.66% D 11.25% Go 15.27% Java 23.09% Julia 16.53% Nim 9.06% Ruby 10.14%

rays's Introduction

rays

Tracker: trello

Ray tracing based language benchmark inspired from:

Reference Image

Reference image rendered using the C++ version: 1 Megapixel (also 2, 3 and 4)

Why?

I have written two blog posts describing the intent behind this:

Reddit discussion thread

Why ray tracing?

  • I picked the "Business card raytracer" as it was written in C++ (so a high value fast target) and extremely concise (so I wouldn't be bored to death porting it to Go)
  • The ray tracing algorithm (as implemented) was inherently parallelizable. I wanted to definitely compare and contrast the ease with which I could just take a single threaded solution and have it quickly scale up to multiple cores
  • I was fascinated with the subject of ray tracing since my highschool days. I had coded up a decent raytracer in VB6 (shudder) and even done rudimentary anti-aliasing, etc. The fact that the end result of a benchmark run was a graphic image acted as a self motivator for me

Why optimize the base algorithm?

Also, shouldn't we leave it to the compilers to do their best

Optimizing in a particular language also gives you a feel of "how far" you can push the boundaries of performance when the need arises. Micro optimizations are the root of all evil, no doubt; but not when the subject matter is benchmarking itself (plus, it doesn't hurt that it makes the process fun)

Think of this as a great opportunity to learn the various nuances of these languages, which are otherwise extremely hard to learn/master.

Different Implementations

Currently, the following versions are currently available, and tracked in their own folders:

  • Go (optimized, multi-threaded)
  • C++ (optimized, multi-threaded, SSE)
  • Java (optimized, multi-threaded)
  • Ruby (multi-threaded)
  • Julia (optimized, single-threaded)
  • Nimrod (optimized, multi-threaded)

Please feel free to implement the benchmark (refer to the original C++ version here) in the language of your choice. All optimizations are welcome but try not to stray away too far from the spirit of the original algorithm. The existing implementations can always act as a litmus test.

Also, optimizations to the existing implementation are obviously welcome. I will regularly update the results based on activity/updates to the code.

How to use

RAYS_HOME

Set RAYS_HOME environment variable to the top level rays folder before running any of the benchmarks

Benchmark Run

The benchmark is to render a 768x768 image with the text:

R A
Y S

A program is valid if it outputs a valid PPM image to STDOUT.

Prerequisite

  • go 1.2rc1 or later
  • gcc 4.8.1 or later
  • Java 7 or later
  • Ruby 2.0.0-p247 / JRuby / Rubinius 2.0
  • Julia 0.2-prerelease
  • GIMP for opening the rendered images

Implemented benchmarks

We currently have implementations from:

  • go
  • C++ (thanks to Takayuki Matsuoka)
  • Java (thanks to Tobias Kalbitz)
  • Ruby (thanks to Michael Macias)
  • Julia (thanks to Jake Bolewski)
  • Nimrod (thanks to Erik O'Leary)

Please refer to individual README files in the specific folders to find out instructions on how to run the specific benchmark.

Current Performance

The current performance stacks up like so:

512x512 image 2048x2048 image 4096x4096 image

Contributors

The following have contributed to the project one way or the other:

Thanks to everyone for all the help given :)

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.