JavaScript Ray Tracing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JavaScript Ray Tracing

Gary Schiltz-4
I'm starting to do a bit of dabbling in mobile development, and have been looking at PhoneGap, which uses HTML/CSS/JavaScript. To get an idea how performant JavaScript is, I looked for a JS web app that would be processor intensive. I found a web app that does ray tracing directly in JavaScript (www.slimeland.com/raytrace). Just for grins, I did some runs in all the browsers on my MacBook Pro (as well as iOS Safari on my iPhone 4S). I don't know how the algorithm would perform if written in C or Java, although I suspect it would be a couple of orders of magnitude faster on either. Anyway, I loaded the "Original JS Raytracer Scene" preset and then ran once with 100x100 resolution and again with 200x200 resolution. The table below has the results for the "pixels per second" achieved (hopefully this message stays in plain text, otherwise the table will look really look like crap...)

                | PPS (100x100)  |  PPS (200x200)
----------------|----------------|---------------
Safari          |    1610        |      575
Firefox         |    1480        |      735
Chrome          |    2422        |     1140
Opera           |    2235        |     1200
IE 10 (VMWare)  |    1180        |      660
iOS Safari      |     185        |       80
-------------------------------------------------

I'm beginning to share the enthusiasm many FRIAMers have for JavaScript. The fact that the same code runs on such a variety of browsers and devices is way cool.

;; Gary
============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com
Reply | Threaded
Open this post in threaded view
|

Re: JavaScript Ray Tracing

Owen Densmore
Administrator
Welcome to the club!  We're finding the advantages of the JavaScript ecology are many.

I know that language fads come and go, and that the client/server split can be used to let any language be used for a web page.  Look how well Python has done, for example.

Emscripten  and Asm.js also promises compiling/transcoding from any language that can be compiled to LLVM to the Asm subset of JS, which in turn targets no worse than 1/2 the performance of optimized C/C++.

But the key is this: browsers.  There is only ONE language that can program the browser and that is JS.  And recent TypedArrays allow JS to talk to any part of the browser, such as webGL and the GPU.

I just don't see JS becoming a "fad".  Its luck but strategic.  And just as there was a time where many languages could compile to the JVM (Java's byte code), JS and Asm.js is now being the compile target for existing languages as well as languages like CoffeeScript, my favorite.

   -- Owen


On Mon, Aug 12, 2013 at 8:16 PM, Gary Schiltz <[hidden email]> wrote:
I'm starting to do a bit of dabbling in mobile development, and have been looking at PhoneGap, which uses HTML/CSS/JavaScript. To get an idea how performant JavaScript is, I looked for a JS web app that would be processor intensive. I found a web app that does ray tracing directly in JavaScript (www.slimeland.com/raytrace). Just for grins, I did some runs in all the browsers on my MacBook Pro (as well as iOS Safari on my iPhone 4S). I don't know how the algorithm would perform if written in C or Java, although I suspect it would be a couple of orders of magnitude faster on either. Anyway, I loaded the "Original JS Raytracer Scene" preset and then ran once with 100x100 resolution and again with 200x200 resolution. The table below has the results for the "pixels per second" achieved (hopefully this message stays in plain text, otherwise the table will look really look like crap...)

                | PPS (100x100)  |  PPS (200x200)
----------------|----------------|---------------
Safari          |    1610        |      575
Firefox         |    1480        |      735
Chrome          |    2422        |     1140
Opera           |    2235        |     1200
IE 10 (VMWare)  |    1180        |      660
iOS Safari      |     185        |       80
-------------------------------------------------

I'm beginning to share the enthusiasm many FRIAMers have for JavaScript. The fact that the same code runs on such a variety of browsers and devices is way cool.

;; Gary
============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com


============================================================
FRIAM Applied Complexity Group listserv
Meets Fridays 9a-11:30 at cafe at St. John's College
to unsubscribe http://redfish.com/mailman/listinfo/friam_redfish.com