elefher / glmatrix

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

Do not create new var for 1/len but use the same var #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Much faster in Chromium (about 40%), slower in Minefield. Strange.

<html>
<script type="text/javascript">
var n = 30000000;
var len = 10;
var d=new Date();
do {
                var l = 10;
                var il = 1/l;
}
while(n--);
var e = new Date() -d;
var n = 30000000;
var len = 10;
var f = new Date();
do {
                var l = 10;
                l = 1/l;

}
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:31

GoogleCodeExporter commented 8 years ago
Hm, in methods it is both faster (albeit not 40%). I really have to benchmark 
in methods from now on, looks like both Firefox (tracing JIT) and Chromium 
(method JIT) only optimize or even compile when running methods.

<html>
<script type="text/javascript">

function a() {
    var l = 10;
    var il = 1/l;
}

function b() {
    var l = 10;
    l = 1/l;
}
var n = 60000000;
var len = 10;
var d=new Date();
do {
                a();
}
while(n--);
var e = new Date() -d;
var n = 60000000;
var len = 10;
var f = new Date();
do {
                b();

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

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

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

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:43

GoogleCodeExporter commented 8 years ago

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