Browse Source

rename benchmarks and unit test HTML files based on pattern established in /examples. Expand float23array benchmark to cover most alternatives.

Ben Houston 12 years ago
parent
commit
e8e453c1b6

+ 1 - 1
test/benchmark/sources.html → test/benchmark/benchmarking_float32array_accesspatterns.html

@@ -25,7 +25,7 @@
 
 
   <!-- add class-based unit tests below -->
   <!-- add class-based unit tests below -->
 
 
-  <script src="core/Float32Array.js"></script>
+  <script src="core/Float32ArrayAccessPatterns.js"></script>
   
   
 </body>
 </body>
 </html>
 </html>

+ 56 - 10
test/benchmark/core/Float32Array.js → test/benchmark/core/Float32ArrayAccessPatterns.js

@@ -1,13 +1,16 @@
 
 
 var array = new Float32Array( 10000 * 3 );
 var array = new Float32Array( 10000 * 3 );
-var value = new THREE.Vector3();
-var value2 = [0,0,0];
-var value3 = new Float32Array( 3 );
 
 
 for( var j = 0, jl = array.length; j < jl; j ++ ) {
 for( var j = 0, jl = array.length; j < jl; j ++ ) {
 	array[j] = j;
 	array[j] = j;
 }
 }
 
 
+var vectorArray = [];
+
+for( var j = 0, jl = array.length/3; j < jl; j ++ ) {
+	vectorArray.push( new THREE.Vector3( j*3, j*3+1, j*3+2 ) );
+}
+
 var Float32ArrayCopyTest = function( array ) {
 var Float32ArrayCopyTest = function( array ) {
 	var x, y, z;
 	var x, y, z;
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
@@ -33,6 +36,7 @@ var Float32ArrayDirectTest = function( array ) {
 
 
 
 
 var Float32ArrayVector3CopyTest = function( array ) {
 var Float32ArrayVector3CopyTest = function( array ) {
+	var value = new THREE.Vector3();
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	  value.x = array[i + 0];
 	  value.x = array[i + 0];
 	  value.y = array[i + 1];
 	  value.y = array[i + 1];
@@ -46,8 +50,8 @@ var Float32ArrayVector3CopyTest = function( array ) {
 	}
 	}
 };
 };
 
 
-
 var Float32ArrayArrayCopyTest = function( array ) {
 var Float32ArrayArrayCopyTest = function( array ) {
+	var value2 = [0,0,0];
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	  value2[0] = array[i + 0];
 	  value2[0] = array[i + 0];
 	  value2[1] = array[i + 1];
 	  value2[1] = array[i + 1];
@@ -62,6 +66,7 @@ var Float32ArrayArrayCopyTest = function( array ) {
 };
 };
 
 
 var Float32ArrayFloat32ArrayCopyTest = function( array ) {
 var Float32ArrayFloat32ArrayCopyTest = function( array ) {
+	var value3 = new Float32Array( 3 );
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	for (var i = 0, il = array.length / 3; i < il; i += 3) {
 	  value3[0] = array[i + 0];
 	  value3[0] = array[i + 0];
 	  value3[1] = array[i + 1];
 	  value3[1] = array[i + 1];
@@ -75,26 +80,67 @@ var Float32ArrayFloat32ArrayCopyTest = function( array ) {
 	}
 	}
 };
 };
 
 
+
+var Vector3ArrayVector3CopyTest = function( array ) {
+	var value = new THREE.Vector3();
+	for (var i = 0, il = vectorArray.length; i < il; i ++ ) {
+	  value.copy( vectorArray[i] );
+	  value.x *= 1.01;
+	  value.y *= 1.03;
+	  value.z *= 0.98;
+	  vectorArray[i].copy( value );
+	}
+};
+
+var Vector3ArrayVector3RefTest = function( array ) {
+	for (var i = 0, il = vectorArray.length; i < il; i ++ ) {
+	  var value = vectorArray[i];
+	  value.x *= 1.01;
+	  value.y *= 1.03;
+	  value.z *= 0.98;
+	}
+};
+
+var Vector3ArrayVector3DirectTest = function( array ) {
+	for (var i = 0, il = vectorArray.length; i < il; i ++ ) {
+	  vectorArray[i].x *= 1.01;
+	  vectorArray[i].y *= 1.03;
+	  vectorArray[i].z *= 0.98;
+	}
+};
+
 var suite = new Benchmark.Suite;
 var suite = new Benchmark.Suite;
 
 
-suite.add('Float32CopyArray', function() {
-  Float32ArrayCopyTest( array );
+suite.add('Float32ArrayFloat32ArrayCopyTest', function() {
+  Float32ArrayFloat32ArrayCopyTest( array );
 });
 });
 
 
 suite.add('Float32DirectArray', function() {
 suite.add('Float32DirectArray', function() {
   Float32ArrayDirectTest( array );
   Float32ArrayDirectTest( array );
 });
 });
 
 
+suite.add('Float32ArrayArrayCopyTest', function() {
+  Float32ArrayArrayCopyTest( array );
+});
+
+suite.add('Float32CopyArray', function() {
+  Float32ArrayCopyTest( array );
+});
+
 suite.add('Float32ArrayVector3CopyTest', function() {
 suite.add('Float32ArrayVector3CopyTest', function() {
   Float32ArrayVector3CopyTest( array );
   Float32ArrayVector3CopyTest( array );
 });
 });
 
 
-suite.add('Float32ArrayArrayCopyTest', function() {
-  Float32ArrayArrayCopyTest( array );
+suite.add('Vector3ArrayVector3Ref', function() {
+  Vector3ArrayVector3RefTest( array );
 });
 });
 
 
-suite.add('Float32ArrayFloat32ArrayCopyTest', function() {
-  Float32ArrayFloat32ArrayCopyTest( array );
+suite.add('Vector3ArrayVector3Direct', function() {
+  Vector3ArrayVector3DirectTest( array );
+});
+
+suite.add('Vector3ArrayVector3Copy', function() {
+  Vector3ArrayVector3CopyTest( array );
 });
 });
 
 
 suite.on('cycle', function(event, bench) {
 suite.on('cycle', function(event, bench) {

+ 0 - 0
test/unit/sources.html → test/unit/unittests_sources.html


+ 0 - 0
test/unit/three-math.html → test/unit/unittests_three-math.html


+ 0 - 0
test/unit/three.html → test/unit/unittests_three.html


+ 0 - 0
test/unit/three.min.html → test/unit/unittests_three.min.html