We are now running a linear algebra performance benchmark in your browser! Please ensure that your seatbelt
is fastened and your tray table is upright while we invert 100x100 matrices.
Performance (MFLOPS)
Geometric mean of scores:
Higher is better: For each benchmark and library, a function is called repeatedly for a certain amount of time.
The number of function calls per seconds is converted into a FLOP rate. As we move right within each test, the matrix size increases.
What tricks are used to increase performance in Numeric?
- Replace inner loop for(j=0;j<n;j++) A[i][j] by the equivalent Ai = A[i]; for(j=0;j<n;j++) Ai[j] ("hoisting" the [i] out of the loop).
- Preallocate Arrays: A = new Array(n) instead of A = [].
- Use Array objects directly (abstractions slow you down). Getters and setters are bad.
- Use for(j=n-1;j>=0;j--) if it is faster.
- Do not put anything in Array.prototype. If you modify Array.prototype, it slows down everything significantly.
- Big Matrix*Matrix product: transpose the second matrix and rearrange the loops to exploit locality.
- Unroll loops.
- Don't nest functions.
- Don't call functions, inline them manually. Except...
- ...big functions can confuse the JIT. If a new code path is run in a function, the function can be deoptimized by the JIT.
- Avoid polymorphism.
- Localize references. For example: replace for(i=n-1;i>=0;i--) x[i] = Math.random(); by rnd = Math.random; for(i=n-1;i>=0;i--) x[i] = rnd();. (Make sure rnd and x really are local variables!)
- Deep lexical scopes are bad. You can create a function without much of a lexical scope by using
new Function('...');.
GC pauses?
If you reload the page, the benchmark will run again and will give slightly different results.
This could be due to GC pauses or other background tasks, DOM updates, etc...
To get an idea of the impact of this, load this page in two or more different tabs (not at the same time,
one after the other) and switch between the tabs and see the differences in the performance chart.