Skip to content

Commit

Permalink
Add JSON option
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson committed Aug 24, 2023
1 parent cb490f9 commit 865a310
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
26 changes: 21 additions & 5 deletions benchmark/bench.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { logTable } from './logTable.js';

let _maxTime = 3000;
let _maxIterations = 100;
let _prewarmIterations = 5;
const LOG_JSON = process.argv.includes( '--json' );
const LONG_RUNNING = process.argv.includes( '--long' );
let _maxTime = LONG_RUNNING ? 15000 : 3000;
let _maxIterations = LONG_RUNNING ? 1000 : 100;
let _prewarmIterations = LONG_RUNNING ? 15 : 5;

const _beforeAll = [];
const _beforeEach = [];
Expand All @@ -13,6 +15,16 @@ const _bench = [];
const _suites = [];
let _current = null;

process.on( 'exit', () => {

if ( LOG_JSON ) {

console.log( JSON.stringify( _suites, undefined, ' ' ) );

}

} );

function findMedian( values ) {

values.sort( ( a, b ) => a - b );
Expand Down Expand Up @@ -91,8 +103,12 @@ export function suite( name, cb ) {
_suites.push( { name, results: _current } );
_current = null;

logTable( _suites[ 0 ], [ 'mean', 'median', 'min', 'max' ] );
_suites.length = 0;
if ( ! LOG_JSON ) {

logTable( _suites[ 0 ], [ 'mean', 'median', 'min', 'max' ] );
_suites.length = 0;

}

_afterAll.length = 0;
_afterEach.length = 0;
Expand Down
13 changes: 9 additions & 4 deletions benchmark/run-benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ Mesh.prototype.raycast = acceleratedRaycast;
BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
BufferGeometry.prototype.disposeBoundsTree = disposeBoundsTree;

const bvh = new MeshBVH( new TorusGeometry( 5, 5, 700, 300 ) );
console.log( '**Extremes**' );
logExtremes( bvh );
console.log();
const LOG_JSON = process.argv.includes( '--json' );
if ( ! LOG_JSON ) {

const bvh = new MeshBVH( new TorusGeometry( 5, 5, 700, 300 ) );
console.log( '**Extremes**' );
logExtremes( bvh );
console.log();

}

suite( 'BVH General', () => {

Expand Down

0 comments on commit 865a310

Please sign in to comment.