Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabfuel committed Aug 8, 2015
2 parents 7ec367f + 10c8d02 commit 67bbcf8
Show file tree
Hide file tree
Showing 48 changed files with 2,972 additions and 228 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
@@ -0,0 +1,4 @@
.git
vendor
build
tools
9 changes: 9 additions & 0 deletions .idea/composerJson.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 64 additions & 46 deletions .idea/prophiler.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Dockerfile
@@ -1,3 +1,4 @@
FROM fabfuel/phalcon
COPY . /var/www/html
EXPOSE 80
RUN curl -sS https://getcomposer.org/installer | php
RUN php composer.phar install -o
34 changes: 34 additions & 0 deletions README.md
Expand Up @@ -91,6 +91,23 @@ $profiler->start('\My\Class::doSomeOtherThing', ['additional' => 'information'],
$profiler->stop();
```

## Aggregations
Prophiler now features benchmark aggregations. These give you a lot more insights and are extremely useful to:
- quickly see the total number of recurring executions (e.g. database or cache queries)
- analyze minimum, maximum and average execution times of recurring executions
- easily see (e.g. accidentally) recurring executions of the same database query
- get a warning, if the total number of executions exceeds a custom threshold
- get a warning, if the maximum execution time exceeds a custom threshold

### Setup
Prophiler comes with some aggregators, but you can easily create your own. To Set up an aggregator, all you need to do is to register the aggregator at the profiler instance:
```php
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Database\QueryAggregator());
$profiler->addAggregator(new \Fabfuel\Prophiler\Aggregator\Cache\CacheAggregator());
```
That's it. You immediately see all database and cache queries, grouped by command/query, including the total number of executions, the total duration of all executions as well as the minimum, maximum and average execution time.


## Logging
You can use Prophiler to log events and other data and view it in the timeline and in the separate "Logs" tab. If you already have a logging infrastructure, you can add the PSR-3 compliant `Logger` adapter to it. Otherwise you can also just instantiate and use it directly:

Expand Down Expand Up @@ -122,6 +139,23 @@ $db->exec('DELETE FROM users WHERE active = 0');
$db->prepare('SELECT * from users WHERE userId = ?');
```

###Cache
To profile Phalcon cache backend requests, you only need to decorate the cache backend with the BackendDecorator. It will benchmark all cache operations automatically. Here is an example with the APC backend:
```php
$cacheFrontend = new \Phalcon\Cache\Frontend\Data(['lifetime' => 172800]);
$cacheBackend = new \Phalcon\Cache\Backend\Apc($cacheFrontend, ['prefix' => 'app-data']);

$cache = \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cacheBackend, $profiler);
```

###Elasticsearch
To profile Elasticsearch requests, you only need to decorate the Elasticsearch client with the ClientDecorator:
```php
$elasticsearch = new Elasticsearch\Client(['your' => 'config']);
$client = new \Fabfuel\Prophiler\Decorator\Elasticsearch\ClientDecorator($client, $profiler);
```


## Tips

###Record session writing
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Expand Up @@ -25,7 +25,9 @@
"squizlabs/php_codesniffer": "~1.0",
"fabfuel/mongo": "~0.4",
"doctrine/orm": "~2.4",
"erusev/parsedown": "~1.1"
"erusev/parsedown": "~1.5",
"phalcon/devtools": "1.3.*@dev",
"elasticsearch/elasticsearch": "~1.3"
},
"suggest": {
"phalcon/devtools": "This tools provide you useful scripts, helping to develop applications that use with Phalcon.",
Expand Down

0 comments on commit 67bbcf8

Please sign in to comment.