提交 e8e453c1 编写于 作者: B Ben Houston

rename benchmarks and unit test HTML files based on pattern established in...

rename benchmarks and unit test HTML files based on pattern established in /examples.  Expand float23array benchmark to cover most alternatives.
上级 b0497080
......@@ -25,7 +25,7 @@
<!-- add class-based unit tests below -->
<script src="core/Float32Array.js"></script>
<script src="core/Float32ArrayAccessPatterns.js"></script>
</body>
</html>
\ No newline at end of file
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 ++ ) {
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 x, y, z;
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 value = new THREE.Vector3();
for (var i = 0, il = array.length / 3; i < il; i += 3) {
value.x = array[i + 0];
value.y = array[i + 1];
......@@ -46,8 +50,8 @@ var Float32ArrayVector3CopyTest = function( array ) {
}
};
var Float32ArrayArrayCopyTest = function( array ) {
var value2 = [0,0,0];
for (var i = 0, il = array.length / 3; i < il; i += 3) {
value2[0] = array[i + 0];
value2[1] = array[i + 1];
......@@ -62,6 +66,7 @@ var Float32ArrayArrayCopyTest = function( array ) {
};
var Float32ArrayFloat32ArrayCopyTest = function( array ) {
var value3 = new Float32Array( 3 );
for (var i = 0, il = array.length / 3; i < il; i += 3) {
value3[0] = array[i + 0];
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;
suite.add('Float32CopyArray', function() {
Float32ArrayCopyTest( array );
suite.add('Float32ArrayFloat32ArrayCopyTest', function() {
Float32ArrayFloat32ArrayCopyTest( array );
});
suite.add('Float32DirectArray', function() {
Float32ArrayDirectTest( array );
});
suite.add('Float32ArrayArrayCopyTest', function() {
Float32ArrayArrayCopyTest( array );
});
suite.add('Float32CopyArray', function() {
Float32ArrayCopyTest( array );
});
suite.add('Float32ArrayVector3CopyTest', function() {
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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册