Skip to content

Commit

Permalink
Detect tideways_xhprof being installed
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Feb 10, 2020
1 parent 216e665 commit 112d5c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This profiling library will auto-detect what you have installed and use that.

The preference order is currently as follows:
1. uprofiler
1. tideways_xhprof
1. tideways
1. xhprof

Expand Down
12 changes: 10 additions & 2 deletions src/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Profiler

const PROFILER_XHPROF = 'xhprof';
const PROFILER_TIDEWAYS = 'tideways';
const PROFILER_TIDEWAYS_XHPROF = 'tideways_xhprof';
const PROFILER_UPROFILER = 'uprofiler';

/**
Expand Down Expand Up @@ -138,8 +139,9 @@ public function shutDown()
/**
* Determines which profiler you're running.
* If you're running multiple (which you shouldn't!),
* It will return them in this preference order :
* It will return them in this preference order:
* 1) uprofiler
* 2) tideways_xhprof
* 2) tideways
* 3) xhprof
*
Expand All @@ -148,7 +150,13 @@ public function shutDown()
private function getProfilerType()
{
$profiler = null;
$extensions = array(self::PROFILER_XHPROF, self::PROFILER_TIDEWAYS, self::PROFILER_UPROFILER);
// NOTE: the list here is reversed
$extensions = array(
self::PROFILER_XHPROF,
self::PROFILER_TIDEWAYS,
self::PROFILER_UPROFILER,
self::PROFILER_TIDEWAYS_XHPROF,
);
foreach ($extensions as $extension) {
$profiler = extension_loaded($extension) ? $extension : $profiler;
}
Expand Down

0 comments on commit 112d5c1

Please sign in to comment.