phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api class.phpgw.php, 1.1.1.1.2.14, 1.1.1.1.2.15 core_


From: Dan Kuykendall <address@hidden>
Subject: [Phpgroupware-cvs] api class.phpgw.php, 1.1.1.1.2.14, 1.1.1.1.2.15 core_functions.inc.php, 1.1.1.1.2.7, 1.1.1.1.2.8 starter.inc.php, 1.1.1.1.2.11, 1.1.1.1.2.12
Date: Fri, 31 Oct 2003 02:44:11 +0000

Update of /cvsroot/phpgroupware/api
In directory subversions:/tmp/cvs-serv12383/api

Modified Files:
      Tag: proposal-branch
        class.phpgw.php core_functions.inc.php starter.inc.php 
Log Message:
added performance timer class and tossed it in the main framework

Index: starter.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/starter.inc.php,v
retrieving revision 1.1.1.1.2.11
retrieving revision 1.1.1.1.2.12
diff -C2 -d -r1.1.1.1.2.11 -r1.1.1.1.2.12
*** starter.inc.php     31 Oct 2003 00:24:58 -0000      1.1.1.1.2.11
--- starter.inc.php     31 Oct 2003 02:44:08 -0000      1.1.1.1.2.12
***************
*** 36,47 ****
        
\****************************************************************************/
  
-       // This isn't used yet
-       function perfgetmicrotime()
-       {
-               list($usec, $sec) = explode(' ',microtime());
-               return ((float)$usec + (float)$sec);
-       }
-       $GLOBALS['debug_timer']['start'] = perfgetmicrotime();
-       
        if (floor(phpversion()) == 3)
        {
--- 36,39 ----

Index: core_functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/core_functions.inc.php,v
retrieving revision 1.1.1.1.2.7
retrieving revision 1.1.1.1.2.8
diff -C2 -d -r1.1.1.1.2.7 -r1.1.1.1.2.8
*** core_functions.inc.php      27 Oct 2003 19:12:06 -0000      1.1.1.1.2.7
--- core_functions.inc.php      31 Oct 2003 02:44:08 -0000      1.1.1.1.2.8
***************
*** 33,36 ****
--- 33,120 ----
         */
  
+       class performance_timer
+       {
+               var $data = Array();
+               var $filename = '';
+ 
+               function performance_timer()
+               {
+               }
+ 
+               function perfgetmicrotime()
+               {
+                       list($usec, $sec) = explode(' ',microtime());
+                       return ((float)$usec + (float)$sec);
+               }
+               
+               function start($name)
+               {
+                       $this->data[$name]['start'] = $this->perfgetmicrotime();
+               }
+               
+               function stop($name)
+               {
+                       $this->data[$name]['stop'] = $this->perfgetmicrotime();
+               }
+ 
+               function end($name)
+               {
+                       $this->stop($name);
+               }
+               
+               function calc_times()
+               {
+                       foreach($this->data as $key=>$val)                      
        
+                       {
+                               if(isset($val['start']) && isset($val['stop']))
+                               {
+                                       $this->data[$key]['duration'] = 
number_format ($val['stop'] - $val['start'], 5);
+                               }       
+                       }
+               }
+ 
+               function save()
+               {
+                       if($this->filename == '')
+                       {
+                               
if(isset($GLOBALS['phpgw_data']['server']['performance_file']))
+                               {
+                                       $this->filename = 
$GLOBALS['phpgw_data']['server']['performance_file'];
+                               }
+                               else
+                               {
+                                       return;
+                               }
+                       }
+ 
+                       $this->calc_times();
+                       $contents = '';
+                       foreach($this->data as $key=>$val)                      
        
+                       {
+                               if(isset($val['duration']))
+                               {
+                                       $contents .= $key.": 
".$val['duration']."\n";
+                               }       
+                       }
+                       if (file_exists($this->filename) &&  
!is_writable($this->filename))
+                       {
+                               return;
+                       }
+                       if (!$handle = fopen($this->filename, 'w+'))
+                       {
+                               return;
+                       }
+ 
+                       if (!fwrite($handle, $contents))
+                       {
+                               return;
+                       }
+       fclose($handle);
+               }
+       }
+ 
+       $GLOBALS['performance_timer'] = new performance_timer();
+       $GLOBALS['performance_timer']->start('phpgw');
+       
        function phpgw_error_trap ($errno, $errstr, $errfile = '', $errline = 
'')
        {

Index: class.phpgw.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.phpgw.php,v
retrieving revision 1.1.1.1.2.14
retrieving revision 1.1.1.1.2.15
diff -C2 -d -r1.1.1.1.2.14 -r1.1.1.1.2.15
*** class.phpgw.php     30 Oct 2003 21:18:14 -0000      1.1.1.1.2.14
--- class.phpgw.php     31 Oct 2003 02:44:08 -0000      1.1.1.1.2.15
***************
*** 114,140 ****
                                /* load up the accounts, preferences and 
application classeses */                       
                                /* and also have them send their appropriate 
data to phpgw_data */
!                               $GLOBALS['debug_timer']['api_aaccount_start']  
= perfgetmicrotime();
                                $this->accounts = 
createobject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
                                $this->accounts->fill_phpgw_data();
!                               $GLOBALS['debug_timer']['api_aaccount_end']    
= perfgetmicrotime();
  
!                               $GLOBALS['debug_timer']['api_acl_start']       
= perfgetmicrotime();
                                $this->acl      = createobject('api_acl');
!                               $GLOBALS['debug_timer']['api_acl_end']         
= perfgetmicrotime();
        
!                               $GLOBALS['debug_timer']['api_pref_start']      
= perfgetmicrotime();
                                $this->prefs = createobject('api_prefs');
                                $this->prefs->fill_phpgw_data();
!                               $GLOBALS['debug_timer']['api_pref_end']        
= perfgetmicrotime();
  
  //$GLOBALS['phpgw_data']['server']['translate_service'] = 'google';
  //$GLOBALS['phpgw_data']['prefs']['api.lang'] = 'es';
!                               $GLOBALS['debug_timer']['api_lang_start']      
= perfgetmicrotime();
                                $this->lang = createobject('api_lang');
                                $this->lang->switchlang();
!                               $GLOBALS['debug_timer']['api_lang_end']        
= perfgetmicrotime();
  
                                $this->apps = createobject('api_apps');
                                $this->apps->fill_phpgw_data();
                                $this->base_classes_loaded = True;
                        }
--- 114,142 ----
                                /* load up the accounts, preferences and 
application classeses */                       
                                /* and also have them send their appropriate 
data to phpgw_data */
!                               
$GLOBALS['performance_timer']->start('api_account');
                                $this->accounts = 
createobject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
                                $this->accounts->fill_phpgw_data();
!                               
$GLOBALS['performance_timer']->stop('api_account');
  
!                               $GLOBALS['performance_timer']->start('api_acl');
                                $this->acl      = createobject('api_acl');
!                               $GLOBALS['performance_timer']->stop('api_acl');
        
!                               
$GLOBALS['performance_timer']->start('api_pref');
                                $this->prefs = createobject('api_prefs');
                                $this->prefs->fill_phpgw_data();
!                               $GLOBALS['performance_timer']->stop('api_pref');
  
  //$GLOBALS['phpgw_data']['server']['translate_service'] = 'google';
  //$GLOBALS['phpgw_data']['prefs']['api.lang'] = 'es';
!                               
$GLOBALS['performance_timer']->start('api_lang');
                                $this->lang = createobject('api_lang');
                                $this->lang->switchlang();
!                               $GLOBALS['performance_timer']->stop('api_lang');
  
+                               
$GLOBALS['performance_timer']->start('api_apps');
                                $this->apps = createobject('api_apps');
                                $this->apps->fill_phpgw_data();
+                               $GLOBALS['performance_timer']->stop('api_apps');
                                $this->base_classes_loaded = True;
                        }
***************
*** 349,352 ****
--- 351,356 ----
                        /* Now pass back to the RPC for final packaging. */
                        $this->rpc->sendtoclient();
+                       $GLOBALS['performance_timer']->stop('phpgw');
+                       $GLOBALS['performance_timer']->save();
                        exit;
                }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]