Skip to content

Instantly share code, notes, and snippets.

View mcuadros's full-sized avatar

Máximo Cuadros mcuadros

View GitHub Profile
@mcuadros
mcuadros / gist:9551290
Last active August 29, 2015 13:57
Mongofill Insert Benchmarks

MongoDB native driver 1.4.5 - PHP 5.5.9-1+sury.org~precise+1

Mongofill\Benchmarks\BsonEvent
    Method Name           Iterations    Average Time      Ops/second
    -------------------  ------------  --------------    -------------
    simpleEncode       : [10,000    ] [0.0000005092382] [1,963,717.40250]
    simpleNestedEncode : [10,000    ] [0.0000507833719] [19,691.48487]
    complexEncode      : [10,000    ] [0.0000015980959] [625,744.67768]
    complexNestedEncode: [10,000    ] [0.0001292291880] [7,738.18992]
    simpleDecode       : [10,000    ] [0.0000009249926] [1,081,089.77498]
@mcuadros
mcuadros / gist:9560576
Last active August 29, 2015 13:57
Mongator Benchmarks @ HHVM + Mongofill

Mongator Benchmarks @ HHVM + Mongofill

Mongator is a simple MongoDB ODM to claims to be 3x faster than Doctrine, now thanks to Mongofill a pure PHP implementation of MongoDB driver, is possible run this package under HHVM.

The benchmarks, are based on athletic.

The native version uses the standard mongo driver, and HHVM is running the lastest mastver version with Mongofill ae5c155 + bson-hni 0.0.1

A bencmarks of a plain version of mongofill can be found at https://gist.github.com/mcuadros/9551290

@mcuadros
mcuadros / gist:9604673
Last active August 29, 2015 13:57
stream_get_meta_data behavior

fopen

Code

<?php
$fp = fsockopen("www.example.com", 80);
if (!$fp) {
    echo "Unable to open\n";
 exit();
@mcuadros
mcuadros / gist:9633632
Created March 19, 2014 01:14
Doctrine Benchmarks @ HHVM + Mongofill

Doctrine @ MongoDB native driver 1.4.5 - PHP 5.5.9-1+sury.org~precise+1

Doctrine\Benchmarks\InsertingEvent
    Method Name             Iterations    Average Time      Ops/second
    ---------------------  ------------  --------------    -------------
    simpleDocument       : [400       ] [0.0039921021461] [250.49459]
    complexDocument      : [400       ] [0.0344979619980] [28.98722]
    complexNestedDocument: [400       ] [0.5473231738806] [1.82707]

void bsonToMongoId(bson_iter_t* iter, Array* output) {
    const bson_oid_t* oid = bson_iter_oid(iter);
    char id[25];

    bson_oid_to_string(oid, id);
   
    TypedValue ret;
    Class* cls = Unit::loadClass(s_MongoId.get());
 ObjectData* obj = ObjectData::newInstance(cls);
@mcuadros
mcuadros / gist:10937820
Created April 16, 2014 22:06
pimple-hack vs pimple (HHVM vs PHP)

pimple-hack vs pimple

Just as a learning practice, i made this port of pimple for hack, this are the results of my little benchmarks based on 1 million of iterations.

The code

<?hh
type Example = (function(): string);
function main() {
$callback = function() {
return 'foo';
};
@mcuadros
mcuadros / gist:59209e4f47395828c297
Last active August 29, 2015 14:01
The Hitchhiker's Guide to the HHVM - Links

REST-HAL endpoints

Summary

Motivation

The requirement of expose the domain via HTTP to other applications.

Services

@mcuadros
mcuadros / gist:5160940
Last active December 14, 2015 22:48
Benchmarking concatenation with heredoc, single-quoted and double-quoted

PHP 5.4.12 (cli) (built: Mar 8 2013 11:16:05)

Method heredoc 1000000 iterations in 1.970294 secs

$var = <<<EOT
<html><head><title>Benchmark Test Page</title></head><body bgcolor=
"$bgcolor" text="$textcolor" {$foo->bar()} link="$link"><p><font face="$fontface"
size="$fontsize"> Here is some test text for the web page.</font>