/**
  * Timer start
  *
  * @param string $methodName Method name
  * @return StopwatchEvent
  */
 protected function _getStopwatchEvent($methodName)
 {
     $tags = array('group' => 'orm::' . $methodName);
     if ($this->_serverName) {
         $tags['server'] = $this->_serverName;
     }
     return $this->_stopwatch->start($tags);
 }
 /**
  * Timer start
  *
  * @param string $methodName Method name
  * @return StopwatchEvent
  */
 protected function _getStopwatchEvent($methodName)
 {
     $tags = $this->_stopwatchAdditionalTags;
     $tags['group'] = 'memcached::' . $methodName;
     if ($this->_serverName) {
         $tags['server'] = $this->_serverName;
     }
     return $this->_stopwatch->start($tags);
 }
Exemple #3
0
function speedTrackExecuteQuery($query)
{
    global $mysqlSpeedString, $swMysqlSum, $mysqlSlowQuery;
    global $printMysqlSpeedString;
    if (!isset($mysqlSpeedString)) {
        $mysqlSpeedString = "";
    }
    if (!isset($printMysqlSpeedString)) {
        $printMysqlSpeedString = FALSE;
    }
    if (!isset($swMysqlSum)) {
        $swMysqlSum = 0;
    }
    if (!isset($mysqlSlowQuery)) {
        $mysqlSlowQuery = 1.0;
    }
    $sw = new Stopwatch();
    $sw->start();
    $result = mysql_query($query);
    $sw->stop();
    $ela = $sw->elapsed();
    $hh = (double) $sw->elapsed();
    $swMysqlSum += $hh;
    if ($hh > $mysqlSlowQuery) {
        $ela = "<font color='red'>{$ela}</font>";
    }
    if ($printMysqlSpeedString) {
        $mysqlSpeedString .= "<br>{$query} - <b>{$ela}</b>";
    }
    if (class_exists("mysqlspeed")) {
        writeMysqlSpeedRecord($query, $hh);
    }
    return $result;
}
 protected function startup()
 {
     parent::startup();
     \Stopwatch::start('BasePresenter');
     AntispamControl::register();
     AntispamControl::$minDelay = 2;
     if ($this->isAjax()) {
         $this->payload->doNotSave = false;
     }
     //$this->getSession('agility')->setExpiration('+ 1 years'); // set up session
     $this->permissionRepository = $this->context->permissionRepository;
     $this->itemRepository = $this->context->itemRepository;
     $this->calendarRepository = $this->context->calendarRepository;
     $this->pages = $this->context->parameters["pageLayout"];
     /** 
      * Create list of used JS and CSS files 
      */
     $this->jsFiles = array(APP_DIR . '/templates/javascript/libs/jquery-1.8.2.min.js', APP_DIR . '/templates/javascript/libs/jquery-ui-1.9.1.custom.min.js', APP_DIR . '/templates/javascript/libs/transify-min.js', APP_DIR . '/templates/javascript/libs/nette.ajax.js', APP_DIR . '/templates/javascript/libs/nette-extension/spinner.ajax.js', APP_DIR . '/templates/javascript/libs/nette-extension/diagnostics.dumps.ajax.js', APP_DIR . '/templates/javascript/libs/netteForms-live.js', APP_DIR . '/templates/javascript/libs/nette-extension/history.ajax.js', 'init.js', 'ui.js', 'calendar.js');
     $this->jsFilesIE['mediaQuery'] = 'ie.mediaqueries.replacement.js';
     $this->cssFiles = array('jqueryui' => 'jquery-ui-1.9.1.custom.min.css', 'calendart' => 'eventCalendar.less', 'screen' => 'screen.less', 'screen.layout' => 'screen.layout.less', 'screen.content' => 'screen.content.less', 'screen.colors' => 'screen.colors.less');
     $this->cssFilesOldIE['IE'] = APP_DIR . '/templates/less/screen.old.ie.less';
     $this->cssFilesPrint['print'] = 'print.less';
     if ($this->getUser()->isLoggedIn()) {
         $this->jsFiles[] = 'admin.js';
     }
 }
 public function testElapsedStepsWithPause()
 {
     $this->stopWatch->start();
     usleep(2500);
     $this->stopWatch->pause();
     usleep(32000);
     $this->stopWatch->step('step1');
     usleep(32000);
     $this->stopWatch->resume();
     usleep(4000);
     $this->stopWatch->pause();
     usleep(32000);
     $this->stopWatch->resume();
     usleep(4000);
     $this->stopWatch->step('step2');
     usleep(8000);
     $this->stopWatch->pause();
     usleep(32000);
     $this->stopWatch->step('step3');
     usleep(32000);
     $this->stopWatch->stop();
     $elapsedSteps = $this->stopWatch->getElapsedStepsMilliseconds();
     $this->assertCount(3, $elapsedSteps);
     $this->assertArrayHasKey('step1', $elapsedSteps);
     $this->assertArrayHasKey('step2', $elapsedSteps);
     $this->assertArrayHasKey('step3', $elapsedSteps);
     $this->assertGreaterThanOrEqual(2, $elapsedSteps['step1']);
     $this->assertLessThan(10, $elapsedSteps['step1']);
     $this->assertGreaterThanOrEqual(10, $elapsedSteps['step2']);
     $this->assertLessThan(18, $elapsedSteps['step2']);
     $this->assertGreaterThanOrEqual(18, $elapsedSteps['step3']);
     $this->assertLessThan(26, $elapsedSteps['step3']);
 }
Exemple #6
0
 function initializeSystemSettings()
 {
     global $dbHost, $dbUser, $dbUserPw, $dbName, $includeDumpJs;
     global $gorumroll, $speedStopWatch, $gorumview, $jQueryLib;
     $_GET = filterInput($_GET);
     $_COOKIE = filterInput($_COOKIE);
     $_SERVER = filterInput($_SERVER);
     $_FILES = filterInput($_FILES);
     if (class_exists("speedstat")) {
         $speedStopWatch = new Stopwatch();
         $speedStopWatch->start();
     }
     ini_set("session.use_cookies", 1);
     ini_set("session.use_only_cookies", 1);
     ini_set("session.use_trans_sid", 0);
     if (!session_id()) {
         session_start();
     }
     $this->kbfu = chr(103) . chr(111) . chr(114) . chr(117) . chr(109) . chr(117) . chr(115) . chr(101) . chr(114);
     $this->kbfk = chr(105) . chr(115) . chr(65) . chr(100) . chr(109);
     $this->kbfr = chr(103) . chr(111) . chr(114) . chr(117) . chr(109) . chr(114) . chr(101) . chr(99) . chr(111) . chr(103) . chr(110) . chr(105) . chr(115) . chr(101) . chr(100);
     // http://hu.php.net/manual/en/reserved.variables.session.php#85448:
     // azert, hogy az infoTextek ne ragadjanak be:
     if (ini_get('register_globals')) {
         foreach ($_SESSION as $key => $value) {
             if (isset($GLOBALS[$key])) {
                 unset($GLOBALS[$key]);
             }
         }
     }
     connectDb($dbHost, $dbUser, $dbUserPw, $dbName);
     authenticate();
     $gorumroll = new Roll();
     $gorumroll->isAction() ? include GORUM_DIR . "/gorum_action.php" : (include GORUM_DIR . "/gorum_view.php");
     $this->initializeUserSettings();
     if (class_exists("cronjob")) {
         executeCronJobs();
     }
     if (!$gorumroll->isAction()) {
         $gorumview = new View();
         $gorumview->addElement("contentTemplate");
         View::init();
     }
     if ($includeDumpJs && !$gorumroll->isAction()) {
         JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib);
         JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.dump.js");
         JavaScript::addInclude(GORUM_JS_DIR . "/dump.js");
     }
     $this->kbf();
 }
include_once $relPath . 'project_states.inc';
include_once $relPath . 'stages.inc';
include_once $relPath . 'LPage.inc';
include_once $relPath . 'Project.inc';
include_once $relPath . 'slim_header.inc';
include_once $relPath . 'misc.inc';
// attr_safe(), html_safe()
include_once $relPath . 'Stopwatch.inc';
include_once './post_files.inc';
include_once "./word_freq_table.inc";
require_login();
define("LAYOUT_HORIZ", 1);
define("LAYOUT_VERT", 2);
$datetime_format = _("%A, %B %e, %Y at %X");
$watch = new Stopwatch();
$watch->start();
set_time_limit(0);
// no time limit
$projectid = validate_projectID('projectid', @$_REQUEST['projectid']);
$encWord = $_GET["word"];
$word = decode_word($encWord);
$timeCutoff = get_integer_param($_REQUEST, 'timeCutoff', 0, 0, null);
enforce_edit_authorization($projectid);
// get the correct layout
$default_layout = @$_SESSION["show_good_word_suggestions_detail"]["layout"];
if (is_null($default_layout)) {
    // The normal case for the session's first visit.
    $default_layout = LAYOUT_HORIZ;
} else {
    if ($default_layout === LAYOUT_HORIZ || $default_layout === LAYOUT_VERT) {
        // The normal case for the session's subsequent visits.
Exemple #8
0
                }
            }
            return $data;
        }
        return htmlentities($data);
    }
}
//Class autoloader
function engineAutoload($class)
{
    if (file_exists("engine/" . $class . ".class.php")) {
        require_once "engine/" . $class . ".class.php";
    }
}
// Register Class Autoloader
spl_autoload_register('engineAutoload');
//Load API
try {
    // Composer autoloader
    if (!file_exists("vendor/autoload.php")) {
        throw new APIexception("Composer not updated. Please update Composer in order to proceed.");
    }
    require 'vendor/autoload.php';
    //Init measure time
    Stopwatch::start();
    $API = new APIhandler();
    echo $API->endpoint_process();
    //echo $API->endpoint_info();
} catch (APIexception $e) {
    echo $e->output();
}
 /**
  * {@inheritDoc}
  */
 public function beforeRender($viewFile)
 {
     $this->_stopwatchEvent = $this->_stopwatch->start(array('server' => 'localhost', 'group' => 'view::render', 'view_template' => basename($viewFile)));
 }
 /**
  * {@inheritDoc}
  */
 public function beforeSave(Model $Model, $options = array())
 {
     $this->_stopwatchEventSave = $this->_stopwatch->start(array('server' => $this->_serverName, 'group' => 'orm::save'));
     return true;
 }
 /**
  * Starts to count
  */
 public static function start()
 {
     self::$start = array_sum(explode(' ', microtime()));
 }