- microtime: documentation ( source)
- preg_match: documentation ( source)
- filter_var: documentation ( source)
- var_export: documentation ( source)
<?php
// your code goes here
$ip = "40.83.109.202";
$start = microtime(true);
$ipchk = !!preg_match("/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/", $ip);
$end = microtime(true);
$start2 = microtime(true);
$ipchk2 = !!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
$end2 = microtime(true);
echo "preg_match:\n";
echo var_export($ipchk, true) . "\n";
echo ($end - $start) * 1000;
echo "\n";
echo "filter_var:\n";
echo var_export($ipchk2, true) . "\n";
echo ($end2 - $start2) * 1000;