Skip to content

Instantly share code, notes, and snippets.

@emanh1
Created November 21, 2016 06:14
Show Gist options
  • Select an option

  • Save emanh1/65f6a9d9457fcc4049f1c94c8221bfe7 to your computer and use it in GitHub Desktop.

Select an option

Save emanh1/65f6a9d9457fcc4049f1c94c8221bfe7 to your computer and use it in GitHub Desktop.
<?php
require __DIR__ . '/Crimp.php';
$TotalTime = 0.0;
$StartTime = microtime( true );
$Crimp = new Crimp( 'CrimpCallback' );
$Crimp->Urls =
[
'https://cloudflare.com',
'https://news.ycombinator.com',
'https://www.google.com',
'https://www.yahoo.com',
];
$Crimp->CurlOptions[ CURLOPT_FOLLOWLOCATION ] = 1;
$Crimp->Go();
$FinalTime = microtime( true ) - $StartTime;
printf( "\nExecution time: %.4f\n", $FinalTime );
printf( "Total cURL time: %.4f\n", $TotalTime );
function CrimpCallback( $Handle, $Data )
{
preg_match( '/<title[^>]*>(.*?)<\/title>/', $Data, $Title );
global $TotalTime; // hurr durr
$Time = curl_getinfo( $Handle, CURLINFO_TOTAL_TIME );
$TotalTime += $Time;
printf(
"%.4f | %-30s | %s\n",
$Time,
substr( $Title[ 1 ], 0, 30 ),
curl_getinfo( $Handle, CURLINFO_EFFECTIVE_URL )
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment