Matrix Concat

Benchmark created on


Setup


class Matrix {

constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0)
{
    this.a  = a;
    this.b  = b;
    this.c  = c;
    this.d  = d;
    this.tx = tx;
    this.ty = ty;
}


concat(m)
{
    return new Matrix(
        this.a  * m.a + this.b  * m.c,
        this.a  * m.b + this.b  * m.d,
        this.c  * m.a + this.d  * m.c,
        this.c  * m.b + this.d  * m.d,
        this.tx * m.a + this.ty * m.c + m.tx,
        this.tx * m.b + this.ty * m.d + m.ty
    );
}

};


Test runner

Ready to run.

Testing in
TestOps/sec
Matrix
let m1 = new Matrix(1, 0, 0, 1, 0, 0);
for (let i = 0; i < 10; i++) {
    m1 = m1.concat(new Matrix(2, 0, 0, 2, 1, 1));
}
ready
DOMMatrix
let m2 = new DOMMatrix([1, 0, 0, 1, 0, 0]);
for (let i = 0; i < 10; i++) {
	m2 = m2.multiply(new DOMMatrix([2, 0, 0, 2, 1, 1]));	
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.