예제 #1
0
/**
 * Initializes our performance info early.
 *
 * Pairs up with get_performance_info() which is actually
 * in moodlelib.php. This function is here so that we can 
 * call it before all the libs are pulled in. 
 *
 * @uses $PERF
 */
function init_performance_info()
{
    global $PERF, $CFG, $USER;
    $PERF = new Object();
    $PERF->dbqueries = 0;
    $PERF->logwrites = 0;
    if (function_exists('microtime')) {
        $PERF->starttime = microtime();
    }
    if (function_exists('memory_get_usage')) {
        $PERF->startmemory = memory_get_usage();
    }
    if (function_exists('posix_times')) {
        $PERF->startposixtimes = posix_times();
    }
    if (function_exists('apd_set_pprof_trace')) {
        // APD profiling
        if ($USER->id > 0 && $CFG->perfdebug >= 15) {
            $tempdir = $CFG->dataroot . '/temp/profile/' . $USER->id;
            mkdir($tempdir);
            apd_set_pprof_trace($tempdir);
            $PERF->profiling = true;
        }
    }
}
예제 #2
0
파일: index.php 프로젝트: rsms/phpab
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
apd_set_pprof_trace();
require_once '../../lib/base/boot.php';
import('../../lib/unittest');
$libTest = new UnitLibraryTestCase('../../lib');
$libTest->test();
$cases = $libTest->getCompletedTestCases();
$favicon = $libTest->passed() ? 'success' : 'failed';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<title>Unit test</title>
		<link rel="icon" href="favicon_<?php 
echo $favicon;
?>
.ico" type="image/x-icon" />
예제 #3
0
/**
 * Profiling function
 *
 * @param unknown_type $start
 * @param unknown_type $path
 * @return unknown
 */
function profile($start = true, &$path)
{
    $outputDirectory = 'www/profiles';
    if (!is_dir(G_ROOTPATH . $outputDirectory)) {
        mkdir(G_ROOTPATH . $outputDirectory, 0755);
    }
    if ($start) {
        if (function_exists('apd_set_pprof_trace') && is_file(G_ROOTPATH . "www/pprofp.php")) {
            $path = apd_set_pprof_trace(G_ROOTPATH . $outputDirectory);
        }
    } else {
        $str = '<a href = "pprofp.php?data_file=' . basename($path) . '&opt=u">' . basename($path) . '</a>';
        return $str;
    }
}
예제 #4
0
 /**
  *  Execute the module wrapped by this invocation.
  *
  *  This function is where the invocationPath is parsed, the WFModule instantiated, and the module executed.
  *
  *  @return string The rendered result of the module invocation.
  *  @throws Any uncaught exception.
  */
 function execute()
 {
     if ($this->module()->shouldProfile()) {
         apd_set_pprof_trace(WFWebApplication::sharedWebApplication()->appDirPath(WFWebApplication::DIR_LOG));
     }
     // execute
     // initialize the request page
     $this->module->requestPage()->initPage($this->pageName);
     // if the responsePage wasn't inited already, then we assume we're going to just display the same page.
     if (!$this->module->responsePage()) {
         $this->module->setupResponsePage();
     }
     // return the rendered HTML of the page. we do this in an output buffer so that if there's an error, we can display it cleanly in the skin rather than have a
     // half-finished template dumped on screen (which is apparently what smarty does when an error is thrown from within it). Have to do this here
     // in addition to WFPage::render() since module/page system can be nested.
     try {
         ob_start();
         $html = $this->module->responsePage()->render();
         ob_end_clean();
     } catch (Exception $e) {
         ob_end_clean();
         throw $e;
     }
     // skin if necessary
     if ($this->skin) {
         $this->skin->setBody($html);
         $html = $this->skin->render(false);
     }
     return $html;
 }
예제 #5
0
파일: main.php 프로젝트: hugcoday/wiki
function main()
{
    if (version_compare(PHP_VERSION, '4.3.10', '<')) {
        exit(_("Your PHP version is too old. You must have at least PHP 4.3.10"));
    }
    if (!USE_DB_SESSION) {
        validateSessionPath();
    }
    global $request;
    if (DEBUG & _DEBUG_APD and extension_loaded("apd")) {
        //apd_set_session_trace(9);
        apd_set_pprof_trace();
    }
    // Postpone warnings
    global $ErrorManager;
    if (defined('E_STRICT')) {
        // and (E_ALL & E_STRICT)) // strict php5?
        $ErrorManager->setPostponedErrorMask(E_NOTICE | E_USER_NOTICE | E_USER_WARNING | E_WARNING | E_STRICT | (check_php_version(5, 3) ? E_DEPRECATED : 0));
    } else {
        $ErrorManager->setPostponedErrorMask(E_NOTICE | E_USER_NOTICE | E_USER_WARNING | E_WARNING);
    }
    $request = new WikiRequest();
    $action = $request->getArg('action');
    if (substr($action, 0, 3) != 'zip') {
        if ($action == 'pdf') {
            $ErrorManager->setPostponedErrorMask(-1);
        }
        // everything
        //else // reject postponing of warnings
        //    $ErrorManager->setPostponedErrorMask(E_NOTICE|E_USER_NOTICE);
    }
    /*
     * Allow for disabling of markup cache.
     * (Mostly for debugging ... hopefully.)
     *
     * See also <<WikiAdminUtils action=purge-cache>>
     */
    if (!defined('WIKIDB_NOCACHE_MARKUP')) {
        if ($request->getArg('nocache')) {
            // 1 or purge
            define('WIKIDB_NOCACHE_MARKUP', $request->getArg('nocache'));
        } else {
            define('WIKIDB_NOCACHE_MARKUP', false);
        }
        // redundant, but explicit
    }
    // Initialize with system defaults in case user not logged in.
    // Should this go into the constructor?
    $request->initializeTheme('default');
    $request->updateAuthAndPrefs();
    $request->initializeLang();
    //FIXME:
    //if ($user->is_authenticated())
    //  $LogEntry->user = $user->getId();
    // Memory optimization:
    // http://www.procata.com/blog/archives/2004/05/27/rephlux-and-php-memory-usage/
    // kill the global PEAR _PEAR_destructor_object_list
    if (!empty($_PEAR_destructor_object_list)) {
        $_PEAR_destructor_object_list = array();
    }
    $request->possiblyDeflowerVirginWiki();
    $validators = array('wikiname' => WIKI_NAME, 'args' => wikihash($request->getArgs()), 'prefs' => wikihash($request->getPrefs()));
    if (CACHE_CONTROL == 'STRICT') {
        $dbi = $request->getDbh();
        $timestamp = $dbi->getTimestamp();
        $validators['mtime'] = $timestamp;
        $validators['%mtime'] = (int) $timestamp;
    }
    // FIXME: we should try to generate strong validators when possible,
    // but for now, our validator is weak, since equal validators do not
    // indicate byte-level equality of content.  (Due to DEBUG timing output, etc...)
    //
    // (If DEBUG if off, this may be a strong validator, but I'm going
    // to go the paranoid route here pending further study and testing.)
    // access hits and edit stats in the footer violate strong ETags also.
    if (1 or DEBUG) {
        $validators['%weak'] = true;
    }
    $request->setValidators($validators);
    $request->handleAction();
    if (DEBUG and DEBUG & _DEBUG_INFO) {
        phpinfo(INFO_VARIABLES | INFO_MODULES);
    }
    $request->finish();
}