experimental-raytracer

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

Github星跟蹤圖

webassembly-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 though. Therefore, I implemented a simplistic raytracer in JavaScript as well as in C++ with a similar code structure while utilizing Emscripten accordingly. For fun, I also translated the code to GLSL and am utilizing WebGL to leverage GPU computing.

For a live demo, please see: https://sniklaus.com/blog/raytracer

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 should soon be 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.

主要指標

概覽
名稱與所有者sniklaus/wasm-raytracer
主編程語言HTML
編程語言C++ (語言數: 4)
平台
許可證GNU General Public License v3.0
所有者活动
創建於2017-12-04 20:37:39
推送於2025-01-06 00:55:08
最后一次提交2025-01-05 16:55:02
發布數0
用户参与
星數174
關注者數5
派生數11
提交數18
已啟用問題?
問題數2
打開的問題數0
拉請求數0
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?