mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 15:34:57 +01:00
129 lines
2.5 KiB
HTML
Executable File
129 lines
2.5 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<body>
|
|
|
|
<script src="../build/three.min.js"></script>
|
|
<script src="../examples/js/math/TypeArrayVector3.js"></script>
|
|
|
|
<script>
|
|
|
|
var Benchmark = function ( title, test ) {
|
|
|
|
var titleDom = document.createElement( 'div' );
|
|
titleDom.style.fontWeight = 'bold';
|
|
titleDom.textContent = title;
|
|
document.body.appendChild( titleDom );
|
|
|
|
var msDom = document.createElement( 'div' );
|
|
document.body.appendChild( msDom );
|
|
|
|
this.run = function () {
|
|
|
|
var start = performance.now();
|
|
|
|
test();
|
|
|
|
msDom.textContent = performance.now() - start;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
var vector11 = new THREE.Vector3( 1.2, 2.3, 3.4 );
|
|
var vector12 = new THREE.Vector3( 1.2, 2.3, 3.4 );
|
|
var vector13 = new THREE.Vector3( 1.2, 2.3, 3.4 );
|
|
|
|
var vector21 = new THREE.TypeArrayVector3( 1.2, 2.3, 3.4 );
|
|
var vector22 = new THREE.TypeArrayVector3( 1.2, 2.3, 3.4 );
|
|
var vector23 = new THREE.TypeArrayVector3( 1.2, 2.3, 3.4 );
|
|
|
|
var benchmarks = [
|
|
|
|
new Benchmark( 'new Vector3()', function () {
|
|
|
|
for ( var i = 0; i < 10000; i ++ ) {
|
|
|
|
var vector = new THREE.Vector3( 1, 1, 1 );
|
|
|
|
}
|
|
|
|
} ),
|
|
|
|
new Benchmark( 'new TypeArrayVector3()', function () {
|
|
|
|
for ( var i = 0; i < 10000; i ++ ) {
|
|
|
|
var vector = new THREE.TypeArrayVector3( 1, 1, 1 );
|
|
|
|
}
|
|
|
|
} ),
|
|
|
|
new Benchmark( 'Vector3 add()', function () {
|
|
|
|
for ( var i = 0; i < 10000000; i ++ ) {
|
|
|
|
vector11.add( vector12 );
|
|
|
|
}
|
|
|
|
} ),
|
|
|
|
new Benchmark( 'TypeArrayVector3 add()', function () {
|
|
|
|
for ( var i = 0; i < 10000000; i ++ ) {
|
|
|
|
vector21.add( vector22 );
|
|
|
|
}
|
|
|
|
} ),
|
|
|
|
new Benchmark( 'Vector3 addVectors()', function () {
|
|
|
|
for ( var i = 0; i < 10000000; i ++ ) {
|
|
|
|
vector11.addVectors( vector12, vector13 );
|
|
|
|
}
|
|
|
|
} ),
|
|
|
|
new Benchmark( 'TypeArrayVector3 addVectors()', function () {
|
|
|
|
for ( var i = 0; i < 10000000; i ++ ) {
|
|
|
|
vector21.addVectors( vector22, vector23 );
|
|
|
|
}
|
|
|
|
} )
|
|
|
|
];
|
|
|
|
function update () {
|
|
|
|
vector11 = new THREE.Vector3( Math.random(), Math.random(), Math.random() );
|
|
vector12 = new THREE.Vector3( Math.random(), Math.random(), Math.random() );
|
|
|
|
vector21 = new THREE.TypeArrayVector3().set( vector11.x, vector11.y, vector11.z );
|
|
vector22 = new THREE.TypeArrayVector3().set( vector12.x, vector12.y, vector12.z );
|
|
|
|
for ( var i = 0, l = benchmarks.length; i < l; i ++ ) {
|
|
|
|
benchmarks[ i ].run();
|
|
|
|
}
|
|
|
|
setTimeout( update, 2000 );
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|