Mongo Write-Speed Test Revision 656463316138 (Mon Feb 27 2012 at 20:41) - Diff Link to this snippet: https://friendpaste.com/5oxfr0SEZBm4CdRGHlnjld Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021222324252627282930313233343536373839<?php/** * Simple speed tester */class SpeedTest{ protected $safe = true; public function run() { $conn = new Mongo(); $collection = $conn->speedtest->coll; $counter = 0; $start = microtime(true); $this->log("Time:\t" . $start); while ($counter++ < 1000000) { $collection->insert(array('counter' => $counter), array('safe' => $this->safe)); } $end = microtime(true); $this->log("Start:\t" . $start); $this->log("End:\t" . $end); $this->log("Diff:\t" . ($end - $start)); $this->log("Avg:\t" . number_format($counter / ($end - $start), 2) . "/s"); } protected function log($str) { echo "{$str}\n"; }}$test = new SpeedTest();$test->run();