'use strict';

var zip = require( './../lib' );

// Simulate some data...
var x = new Array( 1000 ),
	y = new Array( x.length );

for ( var i = 0; i < x.length; i++ ) {
	x[ i ] = Date.now();
	y[ i ] = Math.random() * 100;
}

var zipped,
	start,
	diff,
	elapsed;

start = process.hrtime();
for ( var j = 0; j < 1e6; j++ ) {
	zipped = zip( x, y );
}
diff = process.hrtime( start );

// Elapsed time:
elapsed = diff[ 0 ] + diff[ 1 ]*1e-9;

// Results:
console.log( 'Ops/sec: %d ops', 1e6/elapsed );
console.log( 'Time per op: %d ms', elapsed/1e6*1000 );

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var isArray = require( '@stdlib/assert/is-array' );
var randu = require( '@stdlib/math/base/random/randu' );
var EPS = require( '@stdlib/math/constants/float64-eps' );
var pkg = require( './../package.json' ).name;
var zip = require( './../lib' );


// MAIN //

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

	x = new Array( 100 );
	y = new Array( 100 );
	len = y.length;
	for ( i = 0; i < len; i++ ) {
		x[ i ] = Date.now();
		y[ i ] = ( randu()*100.0 ) + EPS;
	}
	b.tic();
	for ( i = 0; i < b.iterations; i++ ) {
		x[ i % len ] += 10.0;
		o = zip( x, y );
		if ( !isArray( o ) ) {
			b.fail( 'should return an array' );
		}
	}
	b.toc();
	if ( !isArray( o ) ) {
		b.fail( 'should return an array' );
	}
	b.pass( 'benchmark finished' );
	b.end();
});

Switch to using benchmark library