Created
November 21, 2016 06:14
-
-
Save emanh1/65f6a9d9457fcc4049f1c94c8221bfe7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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