⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.177
Server IP:
50.6.168.112
Server:
Linux server-617809.webnetzimbabwe.com 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.4.10
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
.cpan
/
build
/
Data-Validate-IP-0.31-0
/
bench
/
View File Name :
socket-vs-perl
use strict; use warnings; use Benchmark qw( cmpthese ); use Data::Validate::IP; unless ($Data::Validate::IP::HAS_SOCKET) { warn "Cannot load inet_pton from Socket\n"; exit; } my @bad = ('a' .. 'z', undef, 0); my @ipv4 = @bad; for (1 .. 500) { push @ipv4, _random_ipv4(); } my @ipv6 = @bad; push @ipv6, '::', '::0'; for (1 .. 500) { push @ipv6, _random_ipv6(); } cmpthese( 10000, { 'pure Perl ipv4' => sub { Data::Validate::IP::_slow_is_ipv4($_) for @ipv4 }, 'Socket ipv4' => sub { Data::Validate::IP::_fast_is_ipv4($_) for @ipv4 }, } ); cmpthese( 10000, { 'pure Perl ipv6' => sub { Data::Validate::IP::_slow_is_ipv6($_) for @ipv6 }, 'Socket ipv6' => sub { Data::Validate::IP::_fast_is_ipv6($_) for @ipv6 }, } ); sub _random_ipv4 { return join '.', map { int(rand(256)) } 1 .. 4; } sub _random_ipv6 { return join '::', map { sprintf('%4x', int(rand(2**16))) } 1 .. 8; }