Skip to content

Commit

Permalink
Update XHProfService.php
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 authored Aug 27, 2019
1 parent 74d35bd commit 020ae96
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Services/XHProfService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Bavix\XHProf\Providers\ProviderInterface;
use Bavix\XHProf\Providers\XHProfProvider;
use Bavix\XHProf\Providers\EmptyProvider;

use function mt_getrandmax;
use function mt_rand;

class XHProfService
{
Expand All @@ -20,7 +21,8 @@ class XHProfService
*/
public function __construct()
{
if (extension_loaded('xhprof')) {
$freq = config('xhprof.freq', 0.1);
if (extension_loaded('xhprof') && ($freq >= (mt_rand() / mt_getrandmax()))) {
$this->provider = new XHProfProvider();
} else {
$this->provider = new EmptyProvider();
Expand Down

0 comments on commit 020ae96

Please sign in to comment.