Module: nagvis
Branch: master
Commit: 05b077cf69877b00a2c5eb897b299df90efee69e
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=05b077cf69877b00a2c5eb897b299df90efee69e

Author: Lars Michelsen <[email protected]>
Date:   Sat Apr 17 14:32:17 2010 +0200

Added xhprof profiling code

---

 share/frontend/nagvis-js/index.php    |    6 +++++-
 share/server/core/ajax_handler.php    |    6 +++++-
 share/server/core/defines/global.php  |    5 +++++
 share/server/core/functions/debug.php |   12 ++++++++++++
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/share/frontend/nagvis-js/index.php 
b/share/frontend/nagvis-js/index.php
index 4b87ea7..e4984eb 100644
--- a/share/frontend/nagvis-js/index.php
+++ b/share/frontend/nagvis-js/index.php
@@ -35,6 +35,8 @@ require('../../server/core/functions/debug.php');
 require('../../server/core/functions/oldPhpVersionFixes.php');
 require('../../server/core/classes/CoreExceptions.php');
 
+if (PROFILE) profilingStart();
+
 // This defines whether the GlobalMessage prints HTML or ajax error messages
 define('CONST_AJAX' , FALSE);
 
@@ -154,6 +156,8 @@ try {
 
 echo $sContent;
 if (DEBUG&&DEBUGLEVEL&4) debugFinalize();
-exit(1);
+if (PROFILE) 
profilingFinalize('nagvis-js-'.$UHANDLER->get('mod').'-'.$UHANDLER->get('act'));
+
+exit(0);
 
 ?>
diff --git a/share/server/core/ajax_handler.php 
b/share/server/core/ajax_handler.php
index defbe32..89302bf 100644
--- a/share/server/core/ajax_handler.php
+++ b/share/server/core/ajax_handler.php
@@ -33,6 +33,8 @@ require('../../server/core/functions/oldPhpVersionFixes.php');
 require('../../server/core/functions/ajaxErrorHandler.php');
 require('../../server/core/classes/CoreExceptions.php');
 
+if (PROFILE) profilingStart();
+
 // This defines whether the GlobalMessage prints HTML or ajax error messages
 define('CONST_AJAX' , TRUE);
 
@@ -159,6 +161,8 @@ try {
 
 echo $sContent;
 if (DEBUG&&DEBUGLEVEL&4) debugFinalize();
-exit(1);
+if (PROFILE) 
profilingFinalize('core-'.$UHANDLER->get('mod').'-'.$UHANDLER->get('act'));
+
+exit(0);
 
 ?>
diff --git a/share/server/core/defines/global.php 
b/share/server/core/defines/global.php
index 88137bf..a7ce391 100644
--- a/share/server/core/defines/global.php
+++ b/share/server/core/defines/global.php
@@ -38,6 +38,11 @@ set_include_path(
        .PATH_SEPARATOR.'../../server/core/classes/objects/'
 );
 
+// Enable/Disable profiling of NagVis using xhprof.  To make use of this the
+// xhprof php module needs to be loaded and the xhprof_lib directory needs
+// to be available in /var/www.
+define('PROFILE', true);
+
 // enable/disable the debug mode
 define('DEBUG', false);
 
diff --git a/share/server/core/functions/debug.php 
b/share/server/core/functions/debug.php
index 860db57..d045567 100644
--- a/share/server/core/functions/debug.php
+++ b/share/server/core/functions/debug.php
@@ -63,4 +63,16 @@ function microtime_float() {
        list($usec, $sec) = explode(' ', microtime());
        return ((float)$usec + (float)$sec);
 }
+
+function profilingStart() {
+       xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
+}
+
+function profilingFinalize($pre) {
+       include_once "/var/www/xhprof_lib/utils/xhprof_lib.php";
+       include_once "/var/www/xhprof_lib/utils/xhprof_runs.php";
+
+       $xhprof_runs = new XHProfRuns_Default();
+       $xhprof_runs->save_run(xhprof_disable(), 'nagvis-'.$pre);
+}
 ?>


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to