Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Joomla czas wykonania, dziwne zachowanie zmiennej
Forum PHP.pl > Forum > PHP
rafalp
Witam.
chciałem zmierzyć czas wykonania Joomli, plik index.php, dodaje na poczatku i koncu "microtime":
  1. <?php
  2. /**
  3. * @version $Id: index.php 14401 2010-01-26 14:10:00Z louis $
  4. * @package Joomla
  5. * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
  6. * @license GNU/GPL, see LICENSE.php
  7. * Joomla! is free software. This version may have been modified pursuant
  8. * to the GNU General Public License, and as distributed it includes or
  9. * is derivative of works licensed under the GNU General Public License or
  10. * other free or open source software licenses.
  11. * See COPYRIGHT.php for copyright notices and details.
  12. */
  13.  
  14. $c1 = microtime(true);
  15. // Set flag that this is a parent file
  16. define( '_JEXEC', 1 );
  17.  
  18. define('JPATH_BASE', dirname(__FILE__) );
  19.  
  20. define( 'DS', DIRECTORY_SEPARATOR );
  21.  
  22. require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
  23. require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
  24.  
  25.  
  26. JDEBUG ? $_PROFILER->mark( 'afterLoad' ) : null;
  27.  
  28. /**
  29.  * CREATE THE APPLICATION
  30.  *
  31.  * NOTE :
  32.  */
  33. $mainframe =& JFactory::getApplication('site');
  34.  
  35. /**
  36.  * INITIALISE THE APPLICATION
  37.  *
  38.  * NOTE :
  39.  */
  40. // set the language
  41. $mainframe->initialise();
  42.  
  43. JPluginHelper::importPlugin('system');
  44.  
  45. // trigger the onAfterInitialise events
  46. JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
  47. $mainframe->triggerEvent('onAfterInitialise');
  48.  
  49. /**
  50.  * ROUTE THE APPLICATION
  51.  *
  52.  * NOTE :
  53.  */
  54. $mainframe->route();
  55.  
  56. // authorization
  57. $Itemid = JRequest::getInt( 'Itemid');
  58. $mainframe->authorize($Itemid);
  59.  
  60. // trigger the onAfterRoute events
  61. JDEBUG ? $_PROFILER->mark('afterRoute') : null;
  62. $mainframe->triggerEvent('onAfterRoute');
  63.  
  64. /**
  65.  * DISPATCH THE APPLICATION
  66.  *
  67.  * NOTE :
  68.  */
  69. $option = JRequest::getCmd('option');
  70. $mainframe->dispatch($option);
  71.  
  72. // trigger the onAfterDispatch events
  73. JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
  74. $mainframe->triggerEvent('onAfterDispatch');
  75.  
  76. /**
  77.  * RENDER THE APPLICATION
  78.  *
  79.  * NOTE :
  80.  */
  81. $mainframe->render();
  82.  
  83. // trigger the onAfterRender events
  84. JDEBUG ? $_PROFILER->mark('afterRender') : null;
  85. $mainframe->triggerEvent('onAfterRender');
  86.  
  87. /**
  88.  * RETURN THE RESPONSE
  89.  */
  90. echo JResponse::toString($mainframe->getCfg('gzip'));
  91.  
  92. $c2 = microtime(true);
  93.  
  94. $czas = $c2 - $c1;
  95. echo 'CZAS: ' . round($czas,3);
  96.  


Jednak wywala błąd:
Notice: Undefined variable: c1 in xxxxxxxxx\index.php on line 94
Zmienna c1 w jakis sposob znika WTF?

IceManSpy
Nie wiem czy w ten sposób możesz obliczać czas. To tak jakbyś np w Zendzie w pliku index.php umieścił to co tutaj, a tak naprawdę odpala się plik boostrap.php i to on kieruje aplikacją.
rafalp
Zawsze skrypt wychodzi na koniec indexu nie ma bata, tylko tutaj dziwna sprawa bo zmienna c1 po prostu znika z niewiadomego powodu.
echo "CZAS: " wyświetla sie na stronce, tylko ze jest ten Notice o braku zmiennej c1 a przecież ją deklaruje na początku.

  1. require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
  2. require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );


Jak dam po tym c1 to jest ok, ale przed tym coś złego sie dzieje.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.