The following was adapted from:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ php tracked_persistable.php | |
object(MongoDB\Examples\User)#29 (3) { | |
["name"]=> | |
string(7) "alcaeus" | |
["emails"]=> | |
object(MongoDB\Examples\TrackedBSONArray)#24 (0) { | |
} | |
["_id"]=> | |
object(MongoDB\BSON\ObjectId)#15 (1) { | |
["oid"]=> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
enum TimeUnit : string | |
{ | |
case Nanos = 'ns'; | |
case Micros = 'μs'; | |
case Millis = 'ms'; | |
} | |
class TimeUnitString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'vendor/autoload.php'; | |
$client = new MongoDB\Client; | |
$collection = $client->selectCollection('test', 'mr_example'); | |
$collection->drop(); | |
$collection->insertMany([ | |
['x' => 1, 'y' => 1], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$client = new MongoDB\Client(); | |
$db = $client->selectDatabase('test'); | |
// Disable profiling before dropping system.profile | |
$db->command(['profile' => 0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// composer require phpbench/phpbench @dev --dev | |
// vendor/bin/phpbench run MemoryStreamBench.php --report='generator: "table", compare: "revs", cols: ["subject", "mean"]' | |
/** | |
* @Revs(1000) | |
* @Iterations(5) | |
*/ | |
class MemoryStreamBench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
function createNestedDocuments($n, $depth) | |
{ | |
$document = new stdClass; | |
if ($depth < 1) { | |
return $document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ telnet jmikola.net 8888 | |
Trying 97.107.131.54... | |
Connected to jmikola.net. | |
Escape character is '^]'. | |
Hi! | |
208.79.146.242: Hello! | |
208.79.146.242: yo | |
208.79.146.242: hello | |
208.79.146.242: YO | |
208.79.146.242: Bonjour |
For our tests, we used random input data created cat /dev/urandom > random.txt
.
Set the URI, database, and GridFS collection names accordingly. Additionally, decide if the GridFS collection should be dropped before inserting any data.
The number of iterations can be customized. Based on the results, there were modest increases to peak memory on successive iterations. Real memory usage tended to drop with each new iteration and climb again.
By default, the driver uses a chunk size of 255 * 1024
(i.e. 255K). This default seems to leak memory (at least until the file insert completes). Increasing the chunk size even just a bit 256K has vastly better results.
NewerOlder