# Matrix library performance for 3x3

## Preparation HTML

``````<script src="https://cdnjs.cloudflare.com/ajax/libs/vectorious/4.8.1/vectorious.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.11.5/math.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.3.2/gl-matrix.js"></script>``````

## Setup

``````function randomArray(length) {
return Array.apply(null, Array(length)).map(function() {
return Math.round(Math.random());
});
}

var vectoriousA = Matrix.zeros(3, 3).map(Math.random);
var vectoriousB = Matrix.zeros(3, 3).map(Math.random);
var mathjsA = math.map(math.zeros(3, 3), Math.random);
var mathjsB = math.map(math.zeros(3, 3), Math.random);
var glMatrixA = mat3.fromValues.apply(randomArray(9));
var glMatrixB = mat3.fromValues.apply(randomArray(9));
var glMatrixOut = mat3.create();``````

## Test runner

Testing in
TestOps/sec
vectorious 4.8.1
``````vectoriousA.add(vectoriousB);
vectoriousA.subtract(vectoriousB);
vectoriousA.multiply(vectoriousB);``````
math.js 3.11.5
``````math.add(mathjsA, mathjsB);
math.subtract(mathjsA, mathjsB);
math.multiply(mathjsA, mathjsB);``````
glMatrix 2.3.2
``````mat3.add(glMatrixOut, glMatrixA, glMatrixB);
mat3.subtract(glMatrixOut, glMatrixA, glMatrixB);
mat3.multiply(glMatrixOut, glMatrixA, glMatrixB);``````
``````var glMatrixOut = mat3.create();