Created
June 6, 2013 11:27
-
-
Save koke/5720864 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$USERNAME = "q"; | |
$PASSWORD = "q"; | |
function get_response($URL, $context) { | |
if(!function_exists('curl_init')) { | |
die ("Curl PHP package not installed\n"); | |
} | |
/*Initializing CURL*/ | |
$curlHandle = curl_init(); | |
/*The URL to be downloaded is set*/ | |
curl_setopt($curlHandle, CURLOPT_URL, $URL); | |
curl_setopt($curlHandle, CURLOPT_HEADER, false); | |
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context); | |
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); | |
/*Now execute the CURL, download the URL specified*/ | |
$response = curl_exec($curlHandle); | |
return $response; | |
} | |
function upload_file($id) { | |
global $USERNAME, $PASSWORD; | |
$name = "test-${id}M.mpg"; | |
$args = array( | |
0, | |
$USERNAME, | |
$PASSWORD, | |
array( | |
'type' => 'video/mpeg', | |
'name' => $name, | |
'bits' => base64_encode( file_get_contents( $name ) ) | |
) | |
); | |
$request = xmlrpc_encode_request("wp.testUpload", $args); | |
$before = microtime(true); | |
$xmlresponse = get_response("http://andy.local/xmlrpc.php", $request); | |
$response = xmlrpc_decode($xmlresponse); | |
$mem = $response['mem']; | |
$time = microtime(true) - $before; | |
echo $id . ',' . $time . "\n"; | |
} | |
$ids = array(1,2,5,10,50,100,200); | |
foreach ( $ids as $id ) { | |
upload_file( $id ); | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment