Trying to test how long mongo takes to retrieve each document.
However, system()
prints the result to screen and I think that may slow down the process.
How could I supress it from printing to screen?
<?php
$m = new MongoClient();
$db = $m->selectDB("test");
$collection = new MongoCollection($db, "fakestat");
for($i=0;$i<1000;$i++){
$index[]=rand(1,432050);
}
$fp = fopen('logTime.txt','w');
fwrite($fp, "startTimeSec\t startTimeNanoSec\t endTimeSec\t endTimeNanoSec\n");
foreach($index as $val) {
$startTime = system("date +%s'\t'%N");
$results[] = $collection->findOne(array("capture"=>"$val"));
$endTime = system("date +%s'\t'%N");
fwrite($fp, sprintf("%s\t %s\n", $startTime, $endTime));
}
fclose($fp);
$m->close();
?>
Update: Using exec()
and it seems to be work abeit still rather slow.