#!/usr/bin/perl -w use strict; use blib; use XAO::Objects; use XAO::Utils; use XAO::IndexerSupport; use Benchmark; use Getopt::Long; my @saved_argv=@ARGV; my $full_count=500000; my $part_count=2000; my $block_count=500; my $run_count=20; my $no_sysinfo; my $with_perl; GetOptions( 'debug' => sub { XAO::Utils::set_debug(1) }, 'full-count=i' => \$full_count, 'part-count=i' => \$part_count, 'run-count=i' => \$run_count, 'block-count=i' => \$block_count, 'no-system-info' => \$no_sysinfo, 'with-perl' => \$with_perl, ); if(@ARGV<1 || $ARGV[0] ne 'yes') { print < \&sort_null, t3_i_null => \&sort_i_hollow, t3_is_direct => \&sort_is_direct, t3_is_normal => \&sort_is_normal, t3_is_perl => \&sort_is_perl, $with_perl ? ( t2_perl1 => \&sort_perl1, t2_perl2 => \&sort_perl2, ) : ( ), }); exit 0; ############################################################################### sub sort_null { [ 1 ]; } ############################################################################### sub sort_perl1 { my $sorted_ref; # to fool it into thinking we use results for(my $i=0; $i<$block_count; ++$i) { my %t; my $pd=$blocks[$i]; @t{@$pd}=((undef) x scalar(@$pd)); my @sorted=map { exists($t{$_}) ? ($_) : () } @full_data; $sorted_ref=\@sorted; } } ############################################################################### sub sort_perl2 { my %t; @t{@full_data}=(0..$#full_data); my $sorted_ref; for(my $i=0; $i<$block_count; ++$i) { my @sorted=sort { $t{$a} <=> $t{$b} } @{$blocks[$i]}; $sorted_ref=\@sorted; } } ############################################################################### sub sort_i_hollow { my $full=pack('L*',@full_data); my $sorted_ref; for(my $i=0; $i<$block_count; ++$i) { my $part=pack('L*',@{$blocks[$i]}); my @sorted=unpack('L*',$part); $sorted_ref=\@sorted; } } ############################################################################### sub sort_is_direct { my $full=pack('L*',@full_data); XAO::IndexerSupport::template_sort_prepare_do($full); my $sorted_ref; for(my $i=0; $i<$block_count; ++$i) { my $part=pack('L*',@{$blocks[$i]}); XAO::IndexerSupport::template_sort_do($part); my @sorted=unpack('L*',$part); $sorted_ref=\@sorted; } } ############################################################################### sub sort_is_normal { XAO::IndexerSupport::template_sort_prepare(\@full_data); my $sorted_ref; for(my $i=0; $i<$block_count; ++$i) { $sorted_ref=XAO::IndexerSupport::template_sort($blocks[$i]); } } ############################################################################### sub sort_is_perl { XAO::IndexerSupport::template_sort_prepare(\@full_data); my $sorted_ref; for(my $i=0; $i<$block_count; ++$i) { $sorted_ref=[ sort { XAO::IndexerSupport::template_sort_compare($a,$b) } @{$blocks[$i]} ]; } }