@@ -27,6 +27,7 @@ class ERP_mailbox_api
2727{
2828 private $ _functionality_enabled = FALSE ;
2929 private $ _test_only = FALSE ;
30+ private $ _mailbox_starttime = NULL ;
3031
3132 public $ _mailbox = array ( 'description ' => 'INITIALIZATION PHASE ' );
3233
@@ -166,6 +167,8 @@ public function __construct( $p_test_only = FALSE )
166167 # return a boolean for whether the mailbox was successfully processed
167168 public function process_mailbox ( $ p_mailbox )
168169 {
170+ $ this ->_mailbox_starttime = ERP_get_timestamp ();
171+
169172 $ this ->_mailbox = $ p_mailbox + ERP_get_default_mailbox ();
170173
171174 if ( $ this ->_functionality_enabled )
@@ -217,6 +220,7 @@ public function process_mailbox( $p_mailbox )
217220 if ( !$ this ->_test_only && $ this ->_mail_debug )
218221 {
219222 var_dump ( $ this ->_mailbox );
223+ echo "\n" ;
220224 }
221225
222226 $ this ->show_memory_usage ( 'Start process mailbox ' );
@@ -263,7 +267,7 @@ private function pear_error( $p_location, &$p_pear )
263267
264268 if ( !$ this ->_test_only )
265269 {
266- echo "\n\n" . 'Mailbox: ' . $ this ->_mailbox [ 'description ' ] . "\n" . 'Location: ' . $ p_location . "\n" . $ p_pear ->toString () . "\n" ;
270+ echo 'Mailbox: ' . $ this ->_mailbox [ 'description ' ] . "\n" . 'Location: ' . $ p_location . "\n" . $ p_pear ->toString () . "\n \n" ;
267271 }
268272
269273 return ( TRUE );
@@ -291,7 +295,7 @@ private function custom_error( $p_error_text, $p_is_error = TRUE )
291295
292296 if ( !$ this ->_test_only )
293297 {
294- echo "\n\n" . 'Mailbox: ' . $ this ->_mailbox [ 'description ' ] . "\n" . $ t_error_text ;
298+ echo 'Mailbox: ' . $ this ->_mailbox [ 'description ' ] . "\n" . $ t_error_text . "\n\n" ;
295299 }
296300 }
297301
@@ -593,7 +597,7 @@ private function parse_content( &$p_msg )
593597 {
594598 $ this ->show_memory_usage ( 'Start Mail Parser ' );
595599
596- $ t_mp = new ERP_Mail_Parser ( $ this ->_mp_options );
600+ $ t_mp = new ERP_Mail_Parser ( $ this ->_mp_options , $ this -> _mailbox_starttime );
597601
598602 $ t_mp ->setInputString ( $ p_msg );
599603
@@ -1492,12 +1496,14 @@ private function show_memory_usage( $p_location )
14921496 {
14931497 if ( !$ this ->_test_only && $ this ->_mail_debug && $ this ->_mail_debug_show_memory_usage )
14941498 {
1499+ $ t_current_runtime = ( ( $ this ->_mailbox_starttime !== NULL ) ? round ( ERP_get_timestamp () - $ this ->_mailbox_starttime , 4 ) : 0 );
14951500 echo 'Debug output memory usage ' . "\n" .
14961501 'Location: Mail API - ' . $ p_location . "\n" .
1502+ 'Runtime in seconds: ' . $ t_current_runtime . "\n" .
14971503 'Current memory usage: ' . ERP_formatbytes ( memory_get_usage ( FALSE ) ) . ' / ' . $ this ->_memory_limit . "\n" .
14981504 'Peak memory usage: ' . ERP_formatbytes ( memory_get_peak_usage ( FALSE ) ) . ' / ' . $ this ->_memory_limit . "\n" .
14991505 'Current real memory usage: ' . ERP_formatbytes ( memory_get_usage ( TRUE ) ) . ' / ' . $ this ->_memory_limit . "\n" .
1500- 'Peak real memory usage: ' . ERP_formatbytes ( memory_get_peak_usage ( TRUE ) ) . ' / ' . $ this ->_memory_limit . "\n" ;
1506+ 'Peak real memory usage: ' . ERP_formatbytes ( memory_get_peak_usage ( TRUE ) ) . ' / ' . $ this ->_memory_limit . "\n\n " ;
15011507 }
15021508 }
15031509
@@ -1624,4 +1630,13 @@ function ERP_formatbytes( $p_bytes )
16241630
16251631 return ( round ( $ t_bytes , 2 ) . $ t_units [ $ i ] );
16261632 }
1633+
1634+ # --------------------
1635+ # Returns the current timestamp
1636+ function ERP_get_timestamp ()
1637+ {
1638+ $ t_time = explode ( ' ' , microtime () );
1639+ return ( $ t_time [1 ] + $ t_time [0 ] );
1640+ }
1641+
16271642?>
0 commit comments