這個代碼大約需要0.1秒PHP蒙戈的光標速度很慢
// find
$benchmark = Profiler::start ('Testing', 'find()');
$cursor = MongoBG::getInstance ()->setDatabase ('test')->setCollection ('testcoll')->find();
Profiler::stop ($benchmark);
$benchmark = Profiler::start ('Testing', 'cursor walk');
while ($cursor->hasNext()) {
print_r($cursor->getNext());
}
Profiler::stop ($benchmark);
因此「找到()」只用了0.000017秒 但「光標遊走」0.102812秒
收集大約是100行,速度與1000個或僅10個項目相同。
某些服務器信息: 的FreeBSD 8.1,PHP 5.3.5與(蒙戈/ 1.1.4),MongoDB的版本1.6.6預
@mika:我非常懷疑它需要0.0005s的Python連接到數據庫並檢索結果。上述測試不具代表性。 – johndodo 2011-12-19 12:00:54