diff --git a/README.md b/README.md index 887f1aa..428f7aa 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ This project replaces `header.php` approach from xhgui-collector with object bas Supported profilers: - [Tideways XHProf v5.x](#tideways-xhprof-5): PHP >= 7.0 - [XHProf](#xhprof): PHP >= 5.3, PHP >= 7.0 + - [SPX](#spx) - PHP >= 5.6, PHP >= 7.0 - [Tideways v4.x](#tideways-4x): PHP >= 7.0 - [UProfiler](#uprofiler): PHP >= 5.3, < PHP 7.0 @@ -398,3 +399,17 @@ To install `uprofiler` extension, see their [installation documentation][uprofil [UProfiler]: https://github.com/FriendsOfPHP/uprofiler [uprofiler-install]: https://github.com/FriendsOfPHP/uprofiler#installing-the-uprofiler-extension + +### SPX + +To install [SPX profiler], see their [installation documentation][spx-install]. + +Alternatively on `brew` (macOS) you can use package from [glensc/tap] tap: + +``` +brew install glensc/tap/php@7.1-spx +``` + +[glensc/tap]: https://github.com/glensc/homebrew-tap +[spx-install]: https://github.com/NoiseByNorthwest/php-spx#installation +[SPX profiler]: https://github.com/NoiseByNorthwest/php-spx diff --git a/src/Profilers/SpxProfiler.php b/src/Profilers/SpxProfiler.php new file mode 100644 index 0000000..b69a04a --- /dev/null +++ b/src/Profilers/SpxProfiler.php @@ -0,0 +1,52 @@ +readProfile($key); + } + + private function readProfile($key) + { + $profileDir = ini_get('spx.data_dir'); + $json = json_decode(file_get_contents("{$profileDir}/{$key}.json"), true); + + return array_fill(0, $json['call_count'], array()); + + return $json; + } +} diff --git a/tests/Profiler/SpxProfilerTest.php b/tests/Profiler/SpxProfilerTest.php new file mode 100644 index 0000000..5465eec --- /dev/null +++ b/tests/Profiler/SpxProfilerTest.php @@ -0,0 +1,23 @@ +profiler = new SpxProfiler(); + } + + public function testDefaults() + { + $data = $this->runProfiler(); + $this->assertCount(13, $data); + } +}