Three.js closure vs. pre-allocated
JavaScript performance comparison
Preparation code
<script src="https://raw.github.com/mrdoob/three.js/master/build/three.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var A = new THREE.Vector3();
var B = new THREE.Vector3();
var C = new THREE.Vector3();
function setFromCoplanarPoints1( a, b, c ) {
var normal = THREE.Plane.__v1.sub( c, b ).crossSelf(
THREE.Plane.__v2.sub( a, b ) ).normalize();
return normal;
}
var setFromCoplanarPoints2 = (function() {
var v1 = new THREE.Vector3();
var v2 = new THREE.Vector3();
return function ( a, b, c ) {
var normal = v1.sub( c, b ).crossSelf( v2.sub( a, b ) ).normalize();
return normal;
};
})();
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Pre-allocated |
|
pending… |
Closure |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Tapio
- Revision 2: published
- Revision 5: published
0 comments