Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325150

Change subject: profiler: Support tideways for PHP7 profiling
......................................................................

profiler: Support tideways for PHP7 profiling

xhprof does not support PHP7, and it doesn't seem like upstream will be
working on that any time soon.

Tideways is a profiler that is basically a drop-in replacement for
xhprof with functions renamed. So Xhprof::enable() and Xhprof::disable()
will now try to use tideways if that is installed and xhprof is not.

Bug: T152186
Change-Id: I0d7d2de56ac638ca2851c662f527049bd620c0e9
---
M includes/libs/Xhprof.php
M includes/profiler/ProfilerXhprof.php
2 files changed, 23 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/50/325150/1

diff --git a/includes/libs/Xhprof.php b/includes/libs/Xhprof.php
index 9c1ec8e..016c9b1 100644
--- a/includes/libs/Xhprof.php
+++ b/includes/libs/Xhprof.php
@@ -23,6 +23,10 @@
  * <https://github.com/phacility/xhprof>. XHProf can be installed as a PECL
  * package for use with PHP5 (Zend PHP) and is built-in to HHVM 3.3.0.
  *
+ * This also supports using the Tideways profiler
+ * <https://github.com/tideways/php-profiler-extension>, which additionally
+ * has support for PHP7.
+ *
  * @since 1.28
  */
 class Xhprof {
@@ -43,10 +47,16 @@
         */
        public static function enable( $flags = 0, $options = [] ) {
                if ( self::isEnabled() ) {
-                       throw new Exception( 'Xhprof profiling is already 
enabled.' );
+                       throw new Exception( 'Profiling is already enabled.' );
                }
                self::$enabled = true;
-               xhprof_enable( $flags, $options );
+               if ( function_exists( 'xhprof_enable' ) ) {
+                       xhprof_enable( $flags, $options );
+               } elseif ( function_exists( 'tideways_enable' ) ) {
+                       tideways_enable( $flags, $options );
+               } else {
+                       throw new Exception( "Neither xhprof nor tideways are 
installed" );
+               }
        }
 
        /**
@@ -57,7 +67,12 @@
        public static function disable() {
                if ( self::isEnabled() ) {
                        self::$enabled = false;
-                       return xhprof_disable();
+                       if ( function_exists( 'xhprof_disable' ) ) {
+                               return xhprof_disable();
+                       } else {
+                               // tideways
+                               return tideways_disable();
+                       }
                }
        }
 }
diff --git a/includes/profiler/ProfilerXhprof.php 
b/includes/profiler/ProfilerXhprof.php
index 8fc0b77..1bf4f54 100644
--- a/includes/profiler/ProfilerXhprof.php
+++ b/includes/profiler/ProfilerXhprof.php
@@ -43,12 +43,17 @@
  * ($wgProfiler['exclude']) containing an array of function names.
  * Shell-style patterns are also accepted.
  *
+ * It is also possible to use the Tideways PHP extension, which is mostly
+ * a drop-in replacement for Xhprof. Just change the XHPROF_FLAGS_* constants
+ * to TIDEWAYS_FLAGS_*.
+ *
  * @author Bryan Davis <[email protected]>
  * @copyright © 2014 Bryan Davis and Wikimedia Foundation.
  * @ingroup Profiler
  * @see Xhprof
  * @see https://php.net/xhprof
  * @see https://github.com/facebook/hhvm/blob/master/hphp/doc/profiling.md
+ * @see https://github.com/tideways/php-profiler-extension
  */
 class ProfilerXhprof extends Profiler {
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/325150
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d7d2de56ac638ca2851c662f527049bd620c0e9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to