#!/usr/local/bin/perl

use Benchmark;

@int_10 = rand_padded_ints( 10, 4, 8 ) ;
@int_100 = rand_padded_ints( 100, 4, 8 ) ;

print "@int_10\n" ;
print "@int_100\n" ;


#bench_sorts( 1 << 10, [qw(cmp)], [qw( int_10 int_100 )] ) ;

bench_sorts( 1 << 10, [qw(cmp default)], [qw( int_100 )] ) ;

exit( 0 ) ;

sub bench_sorts {

	my( $count, $sorts_ref, $data_names_ref ) = @_ ;

	my( $sort, $data_name, $bench_text ) ;


	$bench_text = <<BENCH ;
timethese ( $count, {
	'null'	=>	sub { null() },
BENCH

	foreach $sort ( 'null', @{$sorts_ref} ) {

		foreach $data_name ( @{$data_names_ref} ) {

			$bench_text .= <<BENCH ;
	'$sort-$data_name' => sub { my( \@sorted ) = sort_$sort( \@$data_name ) },
BENCH
		}
	}

	$bench_text .= <<BENCH ;
} ) ;
BENCH

	print $bench_text ;

	eval $bench_text ;
}



sub null {} ;


sub sort_null {

	@_ ;
}

sub sort_default {

	sort @_ ;
}

sub sort_cmp {

	sort { $a cmp $b } @_ ;
}

sub sort_num {

	sort { $a <=> $b } @_ ;
}
