Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Simple benchmarks for testing the speed of JavaScript matrix libraries adapted from Brandon Jones benchmarks in his glmatrix library:

If you have a browser with WebGL you can run the benchmarks here.

This work is based on Brandon's work as of this commit:

Date:   October 10, 2010 12:49:00 PM EDT
Upped version to 0.9.5

Comparing these matrix libraries:

Changes from Brandon's original benchmark code include:

  • Only including the benchmark code from glmatrix.
  • Updated to the latest mjs as of Dec 15: 16:8e5b0944ef1e and included it in several more tests.
  • Added a graph display of the results using flotr, see:
  • Added tdl library (thanks to Gregg Tavares)
  • each library runs in an iframe so the code won't affect the other libraries (thanks to Gregg Tavares)
  • Added Sylvester library (thanks to Felix E. Klee)

Brandon's original code was released under the New BSD license. My additions to the benchmarking code are released under the same license.

Running locally requires a web server.

With the recent changes by Gregg Tavares that run each library in an iFrame you will need to either:

  • Run the benchmarks from a local web server
  • Configure the browser to allow local file access

Configuring Chrome to allow local file access

On Windows you can add a flag in the shortcut.

On Mac OS X start Chrome from the command line like this:

/Applications/Google\\ Chrome --allow-file-access-from-files

Using Python's SimpleHTTPServer

cd /path/to/webgl-matrix-benchmarks
python -m SimpleHTTPServer

Now open: http://localhost:8000/matrix_benchmark.html

Set up an webgl-matrix-benchmarks.local local host and Apache vhost on Mac OS X

On OS X, turn on Web Sharing via (Apple Menu) -> System Preferences -> Sharing -> Web Sharing

Now, make sure that virtual hosting is enabled by editing /private/etc/apache2/httpd.conf and uncommenting the virtual hosting line (at about line 465 of the stock httpd.conf) as follows:

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

At the top of httpd-vhosts.conf enable name-based virtual hosts for port 80 on all interfaces:

NameVirtualHost *:80

Edit the virtual hosting configuration file /private/etc/apache2/extra/httpd-vhosts.conf to include the entry:

<VirtualHost webgl-matrix-benchmarks.local:80>
   ServerName webgl-matrix-benchmarks
   DocumentRoot /path/to/webgl-matrix-benchmarks
   PassengerEnabled off
   <Directory /path/to/webgl-matrix-benchmarks >
     Options +Indexes +FollowSymLinks +MultiViews +Includes
     AllowOverride All
     Order allow,deny
     Allow from all
     DirectoryIndex matrix_benchmark.html

after making changes test the config: apachectl configtest

When the configuration syntax is correct restart apache: sudo apachectl restart

If there are issues try tailing the general apache2 error log: tail -n 200 -f /var/log/apache2/error_log

For more instructions, set

And, finally, edit your /etc/hosts file to include the following line:       webgl-matrix-benchmarks.local

Confirm that the new entry works:

$ dscacheutil -q host -a name webgl-matrix-benchmarks.local
name: webgl-matrix-benchmarks.local

It might be necessary to flush the local DNS cache:

$ sudo dscacheutil -flushcache

Now open: http://webgl-matrix-benchmarks.local/

Something went wrong with that request. Please try again.