elefher / glmatrix

Automatically exported from code.google.com/p/glmatrix
0 stars 0 forks source link

Change q[x] = -q[x] to *= -1 #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Conclusions:
In this benchmark both Minefield and Chromium *= -1 is fastest as suggested in 
quat4.inverse.

<html>
<script type="text/javascript">
var q = new WebGLFloatArray(3);
var n = 30000000;
var d=new Date();
do {
                q[0] *= -1;
                q[1] *= -1;
                q[2] *= -1;
}
while(n--);
var e = new Date() -d;
var a = 10;
var n = 30000000;
var f = new Date();
do {
                q[0] = -q[0];
                q[1] *= -q[1];
                q[2] *= -q[2];

}
while(--n);
var g = new Date() -f;

alert(e);
alert(g);
</script>
</html>

Original issue reported on code.google.com by danielhe...@gmail.com on 14 Jun 2010 at 6:10

GoogleCodeExporter commented 8 years ago
Oops:

<html>
<script type="text/javascript">
var q = new WebGLFloatArray(3);
var n = 30000000;
var len = 10;
var d=new Date();
do {
                q[0] *= -1;
                q[1] *= -1;
                q[2] *= -1;
}
while(n--);
var e = new Date() -d;
var a = 10;
var n = 30000000;
var len = 10;
var f = new Date();
do {
                q[0] = -q[0];
                q[1] = -q[1];
                q[2] = -q[2];

}
while(--n);
var g = new Date() -f;

alert(e);
alert(g);
</script>
</html>

Slower in Minefield

Original comment by danielhe...@gmail.com on 14 Jun 2010 at 6:27

GoogleCodeExporter commented 8 years ago

Original comment by Tojiro@gmail.com on 1 Jul 2010 at 9:35

GoogleCodeExporter commented 8 years ago

Original comment by Tojiro@gmail.com on 2 Jul 2010 at 4:32

GoogleCodeExporter commented 8 years ago

Original comment by Tojiro@gmail.com on 2 Jul 2010 at 10:02