• Stars
    star
    168
  • Rank 224,166 (Top 5 %)
  • Language
    HTML
  • License
    GNU General Publi...
  • Created almost 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a performance comparison of a simple raytracer in JavaScript, asm.js, WebAssembly, and GLSL

wasm-raytracer

While teaching a web development class, I wanted to present some benchmarks that show the performance benefits of asm.js as well as WebAssembly. I was unfortunately not able to find a suitable reference. Therefore, I implemented a simplistic raytracer in JavaScript as well as in C++ with a similar code structure while utilizing Emscripten to compile the C++ raytracer to asm.js as well as WebAssembly. For fun, I also translated the code to GLSL and am utilizing WebGL to leverage GPU computing.

Screenshot

For a live demo, please see: https://sniklaus.com/wasmray
For a discussion, see Reddit: https://www.reddit.com/r/programming/comments/7k4v5t/

benchmark

Unsurprisingly, the version using GLSL / Shader is significantly faster than the others, showing that it is always important to use the right technology for the right purpose. However, this was not the point of this experiment. Instead, it shows how WebAssembly can potentially be used for an improved performance. To accelerate WebAssembly further, threads could be leveraged. Of course, one could make the argument that a different task could have shown the performance advantages of WebAssembly better. However, I also simply wanted to implement a raytracer.

Browser JavaScript asm.js WebAssembly GLSL / Shader
Firefox 57 ~407.3 ms ~112.3 ms ~87.4 ms ~1.9 ms
Firefox 58 ~358.9 ms ~103.2 ms ~82.7 ms ~1.9 ms
Chrome 62 ~191.7 ms ~167.2 ms ~115.7 ms ~2.1 ms
Chrome 63 ~181.4 ms ~154.2 ms ~120.7 ms ~2.2 ms

Note that the JavaScript performance of Firefox 57 is significantly affected by a bug that has since been fixed. One might also wonder why asm.js in Chrome is slower than JavaScript, which is due to Chrome not having accelerated support for asm.js in the first place.

license

Please refer to the appropriate file within this repository.

More Repositories

1

3d-ken-burns

an implementation of 3D Ken Burns Effect from a Single Image using PyTorch
Python
1,497
star
2

sepconv-slomo

an implementation of Video Frame Interpolation via Adaptive Separable Convolution using PyTorch
Python
1,008
star
3

pytorch-pwc

a reimplementation of PWC-Net in PyTorch that matches the official Caffe version
Python
602
star
4

pytorch-hed

a reimplementation of Holistically-Nested Edge Detection in PyTorch
Python
451
star
5

softmax-splatting

an implementation of softmax splatting for differentiable forward warping using PyTorch
Python
436
star
6

pytorch-liteflownet

a reimplementation of LiteFlowNet in PyTorch that matches the official Caffe version
Python
400
star
7

pytorch-spynet

a reimplementation of Optical Flow Estimation using a Spatial Pyramid Network in PyTorch
Python
298
star
8

pytorch-unflow

a reimplementation of UnFlow in PyTorch that matches the official TensorFlow version
Python
143
star
9

youtube-watchmarker

a browser extension that keeps track of your YouTube watch history and marks videos that you have already watched
JavaScript
141
star
10

pytorch-extension

an example of a CUDA extension for PyTorch using CuPy which computes the Hadamard product of two tensors
Python
118
star
11

revisiting-sepconv

an implementation of Revisiting Adaptive Convolutions for Video Frame Interpolation using PyTorch
Python
77
star
12

arxiv-doom

a parody of the ever-increasing amount of papers that appear on arXiv
HTML
32
star
13

teaching-vision

the framework for my computer vision class, in which the students are ought to solve various exercises
Python
24
star
14

teaching-webdev

the framework for my full stack web development class, in which the students are ought to solve various exercises
HTML
22
star
15

bookmark-tab

JavaScript
14
star
16

teaching-minichess

the framework for my advanced artificial intelligence class, in which an artificial chess player is ought to be implemented
C
14
star
17

nes-memoryview

visualizing the value of each individual byte in an emulated NES as a time series
HTML
9
star
18

teaching-confour

the framework for my advanced artificial intelligence class, in which an connect-four player is ought to be implemented
C
3
star
19

resume

my personal resume written in LaTeX for others to use
HTML
1
star