'use strict';

// MODULES //

var round = require( '@stdlib/math/base/special/round' );
var isnan = require( '@stdlib/math/base/utils/is-nan' );
var asinh = require( './../lib' );


// VARIABLES //

var N = 1e7;


// FUNCTIONS //

function warmup() {
	var i;
	var j;

	j = 0;
	for ( i = 0; i < 1e6; i++ ) {
		j += i * 2;
	}
	if ( j > 0 ) {
		return true;
	}
	return false;
}

function test( name, fcn ) {
	var start;
	var time;
	var bool;
	var x;
	var y;
	var i;

	bool = warmup();
	if ( !bool ) {
		throw new Error( 'Something went wrong.' );
	}
	start = process.hrtime();
	for ( i = 0; i < N; i++ ) {
		x = round( Math.random()*200.0 - 100 );
		y = fcn( x );
	}
	time = process.hrtime( start );
	time = time[ 0 ] + time[ 1 ]*1.0e-9;

	if ( isnan( y ) ) {
		throw new Error( 'Something went wrong.' );
	}
	console.log( 'Test: %s. Elapsed time: %d sec. Iterations: %d. ops/s: %d.', name, time, N, N/time );
}

function benchmark() {
	test( 'Math.asinh', Math.asinh );
	test( 'asinh', asinh );
}


// MAIN //

benchmark();

'use strict';

// MODULES //

var round = require( '@stdlib/math/base/special/round' );
var isnan = require( '@stdlib/math/base/utils/is-nan' );
var asinh = require( './../lib' );


// VARIABLES //

var N = 1e7;


// FUNCTIONS //

function warmup() {
	var i;
	var j;

	j = 0;
	for ( i = 0; i < 1e6; i++ ) {
		j += i * 2;
	}
	if ( j > 0 ) {
		return true;
	}
	return false;
}

function test( name, fcn ) {
	var start;
	var time;
	var bool;
	var x;
	var y;
	var i;

	bool = warmup();
	if ( !bool ) {
		throw new Error( 'Something went wrong.' );
	}
	start = process.hrtime();
	for ( i = 0; i < N; i++ ) {
		x = round( Math.random()*200.0 - 100 );
		y = fcn( x );
	}
	time = process.hrtime( start );
	time = time[ 0 ] + time[ 1 ]*1.0e-9;

	if ( isnan( y ) ) {
		throw new Error( 'Something went wrong.' );
	}
	console.log( 'Test: %s. Elapsed time: %d sec. Iterations: %d. ops/s: %d.', name, time, N, N/time );
}

function benchmark() {
	if ( typeof Math.asinh === 'function' ) {
		test( 'Math.asinh', Math.asinh );
	}
	test( 'asinh', asinh );
}


// MAIN //

benchmark();

Check for native fcn support before running benchmark