Skip to content

Instantly share code, notes, and snippets.

@koke
Created June 6, 2013 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koke/5720864 to your computer and use it in GitHub Desktop.
Save koke/5720864 to your computer and use it in GitHub Desktop.
<?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