-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmongodb.php
40 lines (28 loc) · 852 Bytes
/
mongodb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require 'Benchmark/Timer.php';
$timer = new Benchmark_Timer();
$mongo_cnn = new Mongo();
$points = array(1000, 10000, 100000, 500000, 1000000);
foreach($points as $val){
$mongo_cnn->selectDB("php_db")->selectCollection("dmdb")->drop;
$mongo = $mongo_cnn->selectDB("php_db")->selectCollection("dmdb");
$mongo->insert(array('stub' => 'I am empty init doc'));
$startmark = $val . ' start';
$stopmark = $val . ' stop';
$timer->setMarker($startmark);
cycle($val);
$timer->setMarker($stopmark);
print $val . ': ' . $timer->timeElapsed($startmark, $stopmark) . "\n";
}
function cycle($c){
global $mongo;
for($i = 0; $i<$c; $i++){
$doc = array(
"text" => "i am any text",
"count" => $i,
"coords" => (object)array("x" => 100, "y" => 200, "z" => $i)
);
$mongo->insert($doc);
}
}
?>