Aaron Schulz has uploaded a new change for review.

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


Change subject: Added a wfScopedProfileIn() function to avoid wfProfile() 
whack-a-mole.
......................................................................

Added a wfScopedProfileIn() function to avoid wfProfile() whack-a-mole.

Change-Id: I9f7e0638edd99e1ac07b83054e8f7ef255179281
---
M includes/profiler/Profiler.php
1 file changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/97/60797/1

diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php
index 49d961e..ec60961 100644
--- a/includes/profiler/Profiler.php
+++ b/includes/profiler/Profiler.php
@@ -27,6 +27,24 @@
  */
 
 /**
+ * Begin profiling of a function and returns an object that stops profiling
+ * of a function when that object leaves scope (normally the calling function).
+ *
+ * This is typically called like:
+ * <code>$sp = wfScopedProfileIn( __METHOD__ );</code>
+ *
+ * @param string $functionname name of the function we will profile
+ * @return ScopedCallback
+ * @since 1.22
+ */
+function wfScopedProfileIn( $functionname ) {
+       wfProfileIn( $functionname );
+       return new ScopedCallback( function() use ( $functionname ) {
+               wfProfileOut( $functionname );
+       } );
+}
+
+/**
  * Begin profiling of a function
  * @param string $functionname name of the function we will profile
  */

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

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

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

Reply via email to