<script>"use strict"; //ECMAscript 5
var M3_0 = {
newIdentity: function(){
return {
x1:1., x2:0., x3:0.,
y1:0., y2:1., y3:0.,
z1:0., z2:0., z3:1.};
},
setIdentity: function(m){
m.x1=1., m.x2=0., m.x3=0.;
m.y1=0., m.y2=1., m.y3=0.;
m.z1=0., m.z2=0., m.z3=1.;
return m;
},
newVal: function(
x1,x2,x3,
y1,y2,y3,
z1,z2,z3){
return {
x1:x1, x2:x2, x3:x3,
y1:y1, y2:y2, y3:y3,
z1:z1, z2:z2, z3:z3};
},
setVal: function( m,
x1,x2,x3,
y1,y2,y3,
z1,z2,z3){
m.x1=x1, m.x2=x2, m.x3=x3;
m.y1=y1, m.y2=y2, m.y3=y3;
m.z1=z1, m.z2=z2, m.z3=z3;
return m;
},
newClone: function(m){
return {
x1:m.x1, x2:m.x2, x3:m.x3,
y1:m.y1, y2:m.y2, y3:m.y3,
z1:m.z1, z2:m.z2, z3:m.z3};
},
setCopy: function(src, dst){
dst.x1=src.x1, dst.x2=src.x2, dst.x3=src.x3;
dst.y1=src.y1, dst.y2=src.y2, dst.y3=src.y3;
dst.z1=src.z1, dst.z2=src.z2, dst.z3=src.z3;
return dst;
},
mul_a: function(a,b, out){
// hint for optimizing compiler about aliasing (pointer aliasing)
// https://en.wikipedia.org/wiki/Aliasing_(computing)?oldid=931708672#Conflicts_with_optimization
if(b !== out){ // a==b => a!=out
// a==out => a!=b
var a1=a.x1, a2=a.x2, a3=a.x3;
out.x1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.x2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.x3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
a1=a.y1, a2=a.y2, a3=a.y3;
out.y1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.y2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.y3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
a1=a.z1, a2=a.z2, a3=a.z3;
out.z1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.z2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.z3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
return out;
} else if(a !== b){ // a!=out
return M3_0.mul_b(a,b, out);
} else { // a==out==b
return M3_0.mul_a(a,M3_0.newClone(a), a); //or M3_0.setCopy(M3_0.mul_a(a,a, {}), a) - need to bench
}
},
mul_b: function(a,b, out){
// hint for optimizing compiler about aliasing (pointer aliasing)
// https://en.wikipedia.org/wiki/Aliasing_(computing)?oldid=931708672#Conflicts_with_optimization
if(a !== out){ // b==a => b!=out
// b==out => b!=a
var bx=b.x1, by=b.y1, bz=b.z1;
out.x1 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y1 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z1 = bx*a.z1 + by*a.z2 + bz*a.z3;
bx=b.x2, by=b.y2, bz=b.z2;
out.x2 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y2 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z2 = bx*a.z1 + by*a.z2 + bz*a.z3;
bx=b.x3, by=b.y3, bz=b.z3;
out.x3 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y3 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z3 = bx*a.z1 + by*a.z2 + bz*a.z3;
return out;
} else if(b !== a){ // b!=out
return M3_0.mul_a(a,b, out);
} else { // a==out==b
return M3_0.mul_a(a,M3_0.newClone(a), a); //or M3_0.setCopy(M3_0.mul_a(a,a, {}), a) - need to bench
}
}
};
var M3_1 = function(
x1,x2,x3,
y1,y2,y3,
z1,z2,z3){
//if(this instanceof M3_1){
this.x1=x1, this.x2=x2, this.x3=x3;
this.y1=y1, this.y2=y2, this.y3=y3;
this.z1=z1, this.z2=z2, this.z3=z3;
//} else {
// return new M3_1(
// x1,x2,x3,
// y1,y2,y3,
// z1,z2,z3);
//}
};
M3_1.newIdentity = function(){
return new M3_1(
1.,0.,0.,
0.,1.,0.,
0.,0.,1.);
};
M3_1.setIdentity = function(m){
m.x1=1., m.x2=0., m.x3=0.;
m.y1=0., m.y2=1., m.y3=0.;
m.z1=0., m.z2=0., m.z3=1.;
return m;
};
M3_1.setVal = function( m,
x1,x2,x3,
y1,y2,y3,
z1,z2,z3){
m.x1=x1, m.x2=x2, m.x3=x3;
m.y1=y1, m.y2=y2, m.y3=y3;
m.z1=z1, m.z2=z2, m.z3=z3;
return m;
};
M3_1.newClone = function(m){
return new M3_1(
m.x1, m.x2, m.x3,
m.y1, m.y2, m.y3,
m.z1, m.z2, m.z3);
},
M3_1.setCopy = function(src, dst){
dst.x1=src.x1, dst.x2=src.x2, dst.x3=src.x3;
dst.y1=src.y1, dst.y2=src.y2, dst.y3=src.y3;
dst.z1=src.z1, dst.z2=src.z2, dst.z3=src.z3;
return dst;
};
M3_1.mul_a = function(a,b, out){
// hint for optimizing compiler about aliasing (pointer aliasing)
// https://en.wikipedia.org/wiki/Aliasing_(computing)?oldid=931708672#Conflicts_with_optimization
if(b !== out){ // a==b => a!=out
// a==out => a!=b
var a1=a.x1, a2=a.x2, a3=a.x3;
out.x1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.x2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.x3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
a1=a.y1, a2=a.y2, a3=a.y3;
out.y1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.y2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.y3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
a1=a.z1, a2=a.z2, a3=a.z3;
out.z1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.z2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.z3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
return out;
} else if(a !== b){ // a!=out
return M3_1.mul_b(a,b, out);
} else { // a==out==b
return M3_1.mul_a(a,M3_1.newClone(a), a); //or M3_1.setCopy(M3_1.mul_a(a,a, {}), a) - need to bench
}
};
M3_1.mul_b = function(a,b, out){
// hint for optimizing compiler about aliasing (pointer aliasing)
// https://en.wikipedia.org/wiki/Aliasing_(computing)?oldid=931708672#Conflicts_with_optimization
if(a !== out){ // b==a => b!=out
// b==out => b!=a
var bx=b.x1, by=b.y1, bz=b.z1;
out.x1 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y1 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z1 = bx*a.z1 + by*a.z2 + bz*a.z3;
bx=b.x2, by=b.y2, bz=b.z2;
out.x2 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y2 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z2 = bx*a.z1 + by*a.z2 + bz*a.z3;
bx=b.x3, by=b.y3, bz=b.z3;
out.x3 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y3 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z3 = bx*a.z1 + by*a.z2 + bz*a.z3;
return out;
} else if(b !== a){ // b!=out
return M3_1.mul_a(a,b, out);
} else { // a==out==b
return M3_1.mul_a(a,M3_1.newClone(a), a); //or M3_1.setCopy(M3_1.mul_a(a,a, {}), a) - need to bench
}
};
var M3_2 = {
newIdentity: function(){
return M3_2.newVal(
1.,0.,0.,
0.,1.,0.,
0.,0.,1.);
},
setIdentity: function(m){
m.x1=1., m.x2=0., m.x3=0.;
m.y1=0., m.y2=1., m.y3=0.;
m.z1=0., m.z2=0., m.z3=1.;
return m;
},
newVal: function(
x1,x2,x3,
y1,y2,y3,
z1,z2,z3){
return {
x1:x1, x2:x2, x3:x3,
y1:y1, y2:y2, y3:y3,
z1:z1, z2:z2, z3:z3};
},
setVal: function( m,
x1,x2,x3,
y1,y2,y3,
z1,z2,z3){
m.x1=x1, m.x2=x2, m.x3=x3;
m.y1=y1, m.y2=y2, m.y3=y3;
m.z1=z1, m.z2=z2, m.z3=z3;
return m;
},
newClone: function(m){
return M3_2.newVal(
m.x1, m.x2, m.x3,
m.y1, m.y2, m.y3,
m.z1, m.z2, m.z3);
},
setCopy: function(src, dst){
dst.x1=src.x1, dst.x2=src.x2, dst.x3=src.x3;
dst.y1=src.y1, dst.y2=src.y2, dst.y3=src.y3;
dst.z1=src.z1, dst.z2=src.z2, dst.z3=src.z3;
return dst;
},
mul_a: function(a,b, out){
// hint for optimizing compiler about aliasing (pointer aliasing)
// https://en.wikipedia.org/wiki/Aliasing_(computing)?oldid=931708672#Conflicts_with_optimization
if(b !== out){ // a==b => a!=out
// a==out => a!=b
var a1=a.x1, a2=a.x2, a3=a.x3;
out.x1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.x2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.x3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
a1=a.y1, a2=a.y2, a3=a.y3;
out.y1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.y2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.y3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
a1=a.z1, a2=a.z2, a3=a.z3;
out.z1 = a1*b.x1 + a2*b.y1 + a3*b.z1;
out.z2 = a1*b.x2 + a2*b.y2 + a3*b.z2;
out.z3 = a1*b.x3 + a2*b.y3 + a3*b.z3;
return out;
} else if(a !== b){ // a!=out
return M3_2.mul_b(a,b, out);
} else { // a==out==b
return M3_2.mul_a(a,M3_2.newClone(a), a); //or M3_2.setCopy(M3_2.mul_a(a,a, {}), a) - need to bench
}
},
mul_b: function(a,b, out){
// hint for optimizing compiler about aliasing (pointer aliasing)
// https://en.wikipedia.org/wiki/Aliasing_(computing)?oldid=931708672#Conflicts_with_optimization
if(a !== out){ // b==a => b!=out
// b==out => b!=a
var bx=b.x1, by=b.y1, bz=b.z1;
out.x1 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y1 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z1 = bx*a.z1 + by*a.z2 + bz*a.z3;
bx=b.x2, by=b.y2, bz=b.z2;
out.x2 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y2 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z2 = bx*a.z1 + by*a.z2 + bz*a.z3;
bx=b.x3, by=b.y3, bz=b.z3;
out.x3 = bx*a.x1 + by*a.x2 + bz*a.x3;
out.y3 = bx*a.y1 + by*a.y2 + bz*a.y3;
out.z3 = bx*a.z1 + by*a.z2 + bz*a.z3;
return out;
} else if(b !== a){ // b!=out
return M3_2.mul_a(a,b, out);
} else { // a==out==b
return M3_2.mul_a(a,M3_2.newClone(a), a); //or M3_2.setCopy(M3_2.mul_a(a,a, {}), a) - need to bench
}
}
};
// var prevent_dead_code_elimination = 0.0;
window.prevent_dead_code_elimination_0 = 0.0;
window.prevent_dead_code_elimination_1 = 0.0;
window.prevent_dead_code_elimination_2 = 0.0;
</script>
var a = M3_0.newVal(
7., 9., 3.,
5.,-8., 5.,
-8.,-8.,-5.);
var b = M3_0.newIdentity();
var c = M3_0.newClone(a);
M3_0.mul_a(a,b, a);
M3_0.setVal(b,
0.,-5., 1.,
-8., 5.,-3.,
-5.,-8., 6.);
M3_0.mul_a(c,b, c);
M3_0.mul_a(a,c, b);
M3_0.setVal(a,
-1.,-6., 0.,
0., 5., 5.,
0., 5., 2.);
M3_0.mul_a(b,a, c);
M3_0.setCopy(b, a);
M3_0.mul_a(b,c, b);
M3_0.mul_a(c,a, c);
M3_0.mul_a(a,c, a);
M3_0.mul_a(b,a, b);
M3_0.mul_a(a,b, c);
M3_0.mul_a(c,c, a);
M3_0.setCopy(a, c);
M3_0.setCopy(a, b);
M3_0.mul_a(c,b, a);
M3_0.setVal(c,
1.,-3.,-3.,
2., 0., 2.,
-4., 7.,-8.);
M3_0.mul_a(b,c, b);
M3_0.mul_a(a,b, a);
window.prevent_dead_code_elimination_0 += +a.x1-a.x2+a.x3 -a.y1+a.y2-a.y3 +a.z1-a.z2+a.z3;
var a = new M3_1(
7., 9., 3.,
5.,-8., 5.,
-8.,-8.,-5.);
var b = M3_1.newIdentity();
var c = M3_1.newClone(a);
M3_1.mul_a(a,b, a);
M3_1.setVal(b,
0.,-5., 1.,
-8., 5.,-3.,
-5.,-8., 6.);
M3_1.mul_a(c,b, c);
M3_1.mul_a(a,c, b);
M3_1.setVal(a,
-1.,-6., 0.,
0., 5., 5.,
0., 5., 2.);
M3_1.mul_a(b,a, c);
M3_1.setCopy(b, a);
M3_1.mul_a(b,c, b);
M3_1.mul_a(c,a, c);
M3_1.mul_a(a,c, a);
M3_1.mul_a(b,a, b);
M3_1.mul_a(a,b, c);
M3_1.mul_a(c,c, a);
M3_1.setCopy(a, c);
M3_1.setCopy(a, b);
M3_1.mul_a(c,b, a);
M3_1.setVal(c,
1.,-3.,-3.,
2., 0., 2.,
-4., 7.,-8.);
M3_1.mul_a(b,c, b);
M3_1.mul_a(a,b, a);
window.prevent_dead_code_elimination_1 += +a.x1-a.x2+a.x3 -a.y1+a.y2-a.y3 +a.z1-a.z2+a.z3;
var a = M3_2.newVal(
7., 9., 3.,
5.,-8., 5.,
-8.,-8.,-5.);
var b = M3_2.newIdentity();
var c = M3_2.newClone(a);
M3_2.mul_a(a,b, a);
M3_2.setVal(b,
0.,-5., 1.,
-8., 5.,-3.,
-5.,-8., 6.);
M3_2.mul_a(c,b, c);
M3_2.mul_a(a,c, b);
M3_2.setVal(a,
-1.,-6., 0.,
0., 5., 5.,
0., 5., 2.);
M3_2.mul_a(b,a, c);
M3_2.setCopy(b, a);
M3_2.mul_a(b,c, b);
M3_2.mul_a(c,a, c);
M3_2.mul_a(a,c, a);
M3_2.mul_a(b,a, b);
M3_2.mul_a(a,b, c);
M3_2.mul_a(c,c, a);
M3_2.setCopy(a, c);
M3_2.setCopy(a, b);
M3_2.mul_a(c,b, a);
M3_2.setVal(c,
1.,-3.,-3.,
2., 0., 2.,
-4., 7.,-8.);
M3_2.mul_a(b,c, b);
M3_2.mul_a(a,b, a);
window.prevent_dead_code_elimination_2 += +a.x1-a.x2+a.x3 -a.y1+a.y2-a.y3 +a.z1-a.z2+a.z3;
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
M3_0 | |
M3_1 | |
M3_2 |
Test name | Executions per second |
---|---|
M3_0 | 45042.2 Ops/sec |
M3_1 | 140091.7 Ops/sec |
M3_2 | 58830.5 Ops/sec |
It appears that we have the results of some benchmarking tests for an unknown program, likely a mathematical library or framework. Let's analyze the results and try to understand what they might tell us about the performance of the code.
Benchmark Results
The benchmark results are presented in a table format with three columns:
Benchmarking Test Names
The benchmarking tests are named M3_0
, M3_1
, and M3_2
. These names suggest that they might be related to some kind of mathematical operation or transformation, possibly involving matrix operations (e.g., multiplication).
Results Analysis
Let's look at the results:
Some Observations
Inference
Based on these observations and results, it appears that:
Further Investigation
To further understand the performance differences between these tests, I would recommend:
Please let me know if you have any further questions or if there's anything else I can help with!