Skip to content

Instantly share code, notes, and snippets.

@naoa
Last active August 29, 2015 14:00
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 naoa/11119409 to your computer and use it in GitHub Desktop.
Save naoa/11119409 to your computer and use it in GitHub Desktop.
<?php
$category_file = $argv[1];
$rc = 1;
$startTimeAll = microtime(true);
$fp = fopen($category_file, 'r');
while(!feof($fp)){
$line = fgets($fp);
$line = str_replace(array("\r\n","\r","\n"),'',$line);
if($line != ""){
$startTime = microtime(true);
$query = $line;
$query = urlencode($query);
$url="http://localhost:10041/d/select?table=text&match_columns=title||text&limit=0&match_escalation_threshold=-1&query=" . $query;
$req="GET";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, 10041);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $req);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec ($ch);
curl_close ($ch);
$endTime = microtime(true);
$elapsedTime = $endTime - $startTime;
//$decode_data = json_decode( $data, true);
echo $rc . "," . $elapsedTime . "\n";
$rc++;
}
}
$endTimeAll = microtime(true);
$elapsedTimeAll = $endTimeAll - $startTimeAll;
$rc--;
echo "Total(" . $rc . ") = " . $elapsedTimeAll . "\n";
echo "Average = " . $elapsedTimeAll/$rc . "\n";
fclose($fp)
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment