<commit_before>'use strict';

// MODULES //

var randu = require( '@stdlib/math/base/random/randu' );
var round = require( '@stdlib/math/base/special/round' );
var isEvenFloat64 = require( '@stdlib/math/base/utils/is-even' );
var isEvenInt32 = 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( randu()*100.0 );
		y = fcn( x );
		if ( y !== false && y !== true ) {
			throw new Error( 'Something went wrong.' );
		}
	}
	time = process.hrtime( start );
	time = time[ 0 ] + time[ 1 ]*1.0e-9;

	if ( y !== false && y !== true ) {
		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( 'float64', isEvenFloat64 );
	test( 'int32', isEvenInt32 );

	test( 'float64', isEvenFloat64 );
	test( 'int32', isEvenInt32 );

	test( 'float64', isEvenFloat64 );
	test( 'int32', isEvenInt32 );
}


// MAIN //

benchmark();<commit_msg>Add benchmark<commit_after>'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/math/base/random/randu' );
var float64ToInt32 = require( '@stdlib/math/base/utils/float64-to-float32' );
var isBoolean = require( '@stdlib/utils/is-boolean' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var isEven = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
	var x;
	var y;
	var i;

	b.tic();
	for ( i = 0; i < b.iterations; i++ ) {
		x = ( randu()*1.0e7 ) - 5.0e6;
		y = isEven( float64ToInt32( x ) );
		if ( !isBoolean( y ) ) {
			b.fail( 'should return a boolean' );
		}
	}
	b.toc();
	if ( !isBoolean( y ) ) {
		b.fail( 'should return a boolean' );
	}
	b.pass( 'benchmark finished' );
	b.end();
});
{'fraction_non_alphanumeric': 0.20300751879699247, 'fraction_numerical': 0.030545112781954886, 'mean_word_length': 2.870909090909091, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4047499', 'n_tokens_mistral': 927, 'n_tokens_neox': 856, 'n_words': 232}