C:\test>echo 92.103.2.204 | 874413.pl
92.103.2.204 allocated to user;552
1 lookups (1 found) in 0.011 seconds (0.011339/sec)
C:\test>echo 63.203.110.110 | 874413.pl
63.203.110.110 allocated to user;532
1 lookups (1 found) in 0.012 seconds (0.012047/sec)
C:\test>echo 109.224.107.185 | 874413.pl
109.224.107.185 allocated to user;139
1 lookups (1 found) in 0.012 seconds (0.012018/sec)
C:\test>echo 122.228.116.36 | 874413.pl
122.228.116.36 allocated to user;485
1 lookups (1 found) in 0.013 seconds (0.012670/sec)
C:\test>echo 0.0.0.0 | 874413.pl
1 lookups (0 found) in 0.007 seconds (0.007276/sec)
C:\test>echo 127.0.0.1 | 874413.pl
1 lookups (0 found) in 0.007 seconds (0.007116/sec)
C:\test>echo 2.103.2.204 | 874413.pl
1 lookups (0 found) in 0.008 seconds (0.008237/sec)
####
>perl -MList::Util=shuffle
-nE"chomp(@i=shuffle<>); say +(split':')[0] for @i[0..1e3];last" ips.txt
|874413.pl >nul
1001 lookups (1001 found) in 0.456 seconds (0.000455/sec)
####
#! perl -slw
use strict;
use Time::HiRes qw[ time ];
open IPS, '> 1;
seek IPS, $pos*6, 0;
( $ip, $u ) = unpack 'Nn', ;
$hi = $pos - 1, next if $ip > $toFind;
$lo = $pos + 1, next if $ip < $toFind;
return join('.',unpack'C4',pack'N',$ip), $u if $ip == $toFind;
}
return;
}
my $start = time;
my $found = 0;
while( <> ) {
chomp;
my( $ip, $user ) = find( $_ );
#warn "$_ unassigned\n" and
next unless $user;
++$found;
printf "%s allocated to user;%u\n", $ip, $user;
}
my $taken = time() - $start;
warn sprintf "%d lookups ($found found) in %.3f seconds (%.6f/sec)\n",
$., $taken, $taken / $.;