public function testDifferentStopwatchesDoNotShareState()
 {
     $firstStopwatch = stopwatch();
     usleep(100);
     $secondStopwatch = stopwatch();
     assertThat($this->getElapsedSeconds($firstStopwatch), not($this->getElapsedSeconds($secondStopwatch)));
 }
Esempio n. 2
0
function resultMeasure($div = 1)
{
    global $db;
    $proctime = stopwatch();
    if ($db) {
        $dbpercent = round($db->time_queries / $proctime * 100, 2);
    }
    echo "Zeit/{$div}: " . $proctime / $div . "s (" . (100 - $dbpercent) . "% PHP - " . ($dbpercent ? "{$dbpercent}" : "0") . "% MySQL) <br>\n";
}
Esempio n. 3
0
function resultMeasure($div = 1)
{
    global $db;
    $proctime = stopwatch();
    if (isset($db)) {
        $dbpercent = round($db->getQueryTime() / $proctime * 100, 2);
        echo "Zeit/{$div}: " . $proctime / $div . "s (" . (100 - $dbpercent) . "% PHP - " . ($dbpercent ? "{$dbpercent}" : "0") . "% MySQL) <br>\n";
    }
}
Esempio n. 4
0
function page_end($watch = true)
{
    global $db, $config;
    if ($config->RUN_TIMER || $watch) {
        $proctime = stopwatch();
        $dbpercent = round($db->time_queries / $proctime * 100, 2);
        // FIXME: has to be localized
        echo "<!-- Seite aufgebaut in " . $proctime . " Sekunden (" . (100 - $dbpercent) . "% PHP - " . $dbpercent . "% MySQL) mit " . $db->num_queries . " Abfragen -->";
    }
}
Esempio n. 5
0
function page_end($watch = true)
{
    global $db;
    if (Config::RUN_TIMER || $watch) {
        $proctime = stopwatch();
        $dbpercent = round($db->getQueryTime() / $proctime * 100, 2);
        echo "\n<!-- Seite aufgebaut in " . $proctime . " Sekunden (" . (100 - $dbpercent) . "% PHP - " . $dbpercent . "% MySQL) mit " . $db->getQueryCount() . " Abfragen in " . $db->getQueryTime() . "Sek. -->";
        echo "\n<!-- Memory Usage: " . page_memoryConvert(memory_get_usage(true)) . " -->";
    }
    $db = NULL;
}
Esempio n. 6
0
function monitorExecution(callable $function)
{
    $report = new ExecutionReport();
    $stopwatch = stopwatch();
    try {
        $function();
    } catch (\Exception $e) {
        $report->exception = $e;
    }
    list($report->dateStart, $report->dateFinish, $report->elapsedSeconds) = $stopwatch();
    return $report;
}
/*
for($i=0;$i<250;$i++){
if(strlen($ar[$i])>20)filewrite("out/".$lang[$i].".txt",$ar[$i]);

}
*/
// //////////////////////////////////////////////////////


// echo "<pre>".$ar[85]."</pre>";

echo "
<br />
<hr size=1 noshade width=950>
<table width=950><tr><td>
<small>Page time: " . substr( ( stopwatch() - $start ), 0, 5 ) . " seconds</small>
<td align=right>

<small>Script based on work contributed by <a href=http://www.dicts.info/>Zdenek Broz</a>
</small>
</td>
</tr></table>
<br />";


function filewrite( $file, $txt ) {
$fw = fopen( $file, "w+" );
fwrite( $fw, $txt . "\n" );
fclose( $fw );
}
Esempio n. 8
0
    ob_flush();
    flush();
    if ($pause_count > $pause_amount) {
        sleep($pause_time);
        $pause_count = 1;
    }
    // Default sleep to reduce server-load: 1 second.
    sleep(1);
    $c++;
    $pause_count++;
}
ob_end_flush();
echo "<div style='position:absolute;left:10px;top:50px'><br />";
echo LAN_MAILOUT_62 . " " . $send_ok . "<br />";
echo LAN_MAILOUT_63 . " " . $send_fail . "<br />";
echo LAN_MAILOUT_64 . " " . stopwatch() . " " . LAN_MAILOUT_65 . "<br />";
echo "</div>";
// Complete - need to log something against the mailshot entry, and maybe write an admin log entry.
$log_string = date("H:i:s d.m.y") . "  End of " . ($logenable == 1 ? 'debug ' : '') . "mail run by " . USERNAME . " - {$send_ok} succeeded, {$send_fail} failed. Subject: " . $mail_subject;
if (!is_array($email_info['send_results'])) {
    $email_info['send_results'] = array();
}
$email_info['send_results'][] = $log_string;
$sql->db_Update('generic', "`gen_chardata`='" . serialize($email_info) . "' WHERE `gen_id` = {$mail_text_id} AND `gen_type`='savemail' and `gen_datestamp` = '" . $mail_id . "' ");
$mail->ClearAttachments();
if ($pref['mailer'] == 'smtp') {
    $mail->SmtpClose();
}
echo "<div style='text-align:center;margin-left:auto;margin-right:auto;position:absolute;left:10px;top:110px'>\n\t<br /><input type='button' class='btn btn-default button' name='close' value='Close' onclick=\"window.close()\" />\n     </div>";
echo "</body></html>";
if ($logenable) {
Esempio n. 9
0
					$pageterms++;
				}
			}
			//Print $db2->f("ItemNum") . " = " . $terms . " Terms<br>" . stopwatch() . "<br>";
			if ($pageterms > 10000){
				//print "Trying to redirect! Count= $totalterms";
				//print "Location: listing_index.php?totalterms=" . $totalterms . "&count=" . $count . "&itemID=" . $db->f("itemID");
				//exit;
				header("Location: listing_index.php?totalterms=" . $totalterms . "&count=" . $count . "&itemID=" . $db->f("itemID"));
				exit;
			}
		}
	}
	Print "Total Records Indexed = " . $count . " Items<br>";
	Print "Total Index Terms Added = " . $totalterms . " Terms<br>";
	stopwatch();
//Show Page @1-A025E414
$Header->Show("Header");
$Footer->Show("Footer");
$Tpl->PParse("main", false);
//End Show Page

//Unload Page @1-AB7622EF
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
unset($Tpl);
//End Unload Page
function getmicrotime(){
   list($usec, $sec) = explode(" ",microtime());
   return ((float)$usec + (float)$sec);
   }
function stopwatch() {
Esempio n. 10
0
/**
 * Debug Logging to Syslog
 *
 * The global debug level is turned on in your configuration file by setting:
 * <code>
 *	$config->custom->debug['level'] = 255;
 * </code>
 * together with atleast one output direction (currently file and syslog are supported).
 * <code>
 *	$config->custom->debug['file'] = '/tmp/pla_debug.log';
 *	$config->custom->debug['syslog'] = true;
 * </code>
 *
 * The debug level is turned into binary, then if the message levels bit is on
 * the message will be sent to the debug log. (Thus setting your debug level to 255,
 * all bits on, will results in all messages being printed.)
 *
 * The message level bits are defined here.
 *  0(  1) = Entry/Return results from function calls.
 *  1(  2) = Configuration Processing
 *  2(  4) = Template Processing
 *  3(  8) = Schema Processing
 *  4( 16) = LDAP Server Communication
 *  5( 32) = Tree Processing
 *  7( 64) = Other non generic messages
 * @param string $msg Message to send to syslog
 * @param int $level Log bit number for this message.
 * @see syslog.php
 */
function debug_log($msg, $level = 0)
{
    global $config, $debug_file, $timer;
    # In case we are called before we are fully initialised or if debugging is not set.
    if (!isset($config) || !($config->GetValue('debug', 'file') || $config->GetValue('debug', 'syslog'))) {
        return false;
    }
    $debug_level = $config->GetValue('debug', 'level');
    if (!$debug_level || !($level & $debug_level)) {
        return;
    }
    $caller = basename($_SERVER['PHP_SELF']);
    if (func_num_args() > 2) {
        $args = func_get_args();
        array_shift($args);
        array_shift($args);
        $fargs = array();
        foreach ($args as $key) {
            if (is_array($key) || is_object($key)) {
                array_push($fargs, serialize($key));
            } else {
                array_push($fargs, $key);
            }
        }
        $msg = vsprintf($msg, array_values($fargs));
    }
    if (function_exists('stopwatch')) {
        $timer = stopwatch();
    } else {
        $timer = null;
    }
    $debug_message = sprintf('[%2.3f] %s(%s): %s', $timer, basename($_SERVER['PHP_SELF']), $level, substr($msg, 0, 200));
    if ($debug_file || $config->GetValue('debug', 'file')) {
        if (!$debug_file) {
            $debug_file = fopen($config->GetValue('debug', 'file'), 'a');
        }
        fwrite($debug_file, $debug_message . "\n");
    }
    if ($config->GetValue('debug', 'syslog')) {
        syslog_notice($debug_message);
    }
    return syslog_notice(sprintf('%s(%s): %s', $caller, $level, $msg));
}
Esempio n. 11
0
/**
 * Debug Logging
 *
 * The global debug level is turned on in your configuration file by setting:
 * <code>
 *	$config->custom->debug['level'] = 255;
 * </code>
 * together with atleast one output direction (currently file and syslog are supported).
 * <code>
 *	$config->custom->debug['file'] = '/tmp/app_debug.log';
 *	$config->custom->debug['syslog'] = true;
 * </code>
 *
 * The debug level is turned into binary, then if the message levels bit is on
 * the message will be sent to the debug log. (Thus setting your debug level to 255,
 * all bits on, will results in all messages being printed.)
 *
 * The message level bits are defined here.
 *  0(  1) = Entry/Return results from function calls.
 *  1(  2) = Configuration Processing
 *  2(  4) = Template Processing
 *  3(  8) = Schema Processing
 *  4( 16) = LDAP Server Communication
 *  5( 32) = Tree Processing
 *  7( 64) = Other non generic messages
 *  8(128) = Page Processing
 *  9(256) = Hooks Processing
 * @param string Message to send to syslog
 * @param int Log bit number for this message.
 * @see syslog.php
 */
function debug_log($msg, $level, $indent)
{
    static $debug_file;
    # In case we are called before we are fully initialised or if debugging is not set.
    if (!isset($_SESSION[APPCONFIG]) || !($_SESSION[APPCONFIG]->getValue('debug', 'file') || $_SESSION[APPCONFIG]->getValue('debug', 'syslog'))) {
        return;
    }
    $debug_level = $_SESSION[APPCONFIG]->getValue('debug', 'level');
    if (!$debug_level || !($level & $debug_level)) {
        return;
    }
    if ($_SESSION[APPCONFIG]->getValue('debug', 'addr')) {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] == $_SESSION[APPCONFIG]->getValue('debug', 'addr')) {
            $debugaddr = true;
        } elseif ($_SERVER['REMOTE_ADDR'] == $_SESSION[APPCONFIG]->getValue('debug', 'addr')) {
            $debugaddr = true;
        } else {
            $debugaddr = false;
        }
    } else {
        $debugaddr = true;
    }
    if (!$debugaddr) {
        return;
    }
    # If we are limiting debug to a browser, then check that
    $caller = basename($_SERVER['PHP_SELF']);
    $args = func_get_args();
    # Discard our first three arguments.
    array_shift($args);
    array_shift($args);
    array_shift($args);
    # Pull the file/line/method
    if (is_string($args[0]) && preg_match('/.php$/', $args[0])) {
        $file = preg_replace('/.php$/', '', array_shift($args));
        $line = array_shift($args);
        $method = array_shift($args);
    } else {
        $file = 'UNKNOWN';
        $line = 'UNKNOWN';
        $method = 'UNKNOWN';
    }
    # TEMP: New debuglog format
    if (preg_match('/%%/', $msg) && $args[0] != 'NOARGS') {
        $args = array_shift($args);
    }
    $fargs = array();
    foreach ($args as $key) {
        if (is_array($key)) {
            array_push($fargs, serialize($key));
        } elseif (is_object($key)) {
            array_push($fargs, sprintf('OBJECT:%s', get_class($key)));
        } else {
            array_push($fargs, $key);
        }
    }
    if (preg_match('/%%/', $msg)) {
        $msg = preg_replace('/%%/', join('|', $fargs), $msg);
    } else {
        $msg = vsprintf($msg, array_values($fargs));
    }
    if (function_exists('stopwatch')) {
        $timer = stopwatch();
    } else {
        $timer = null;
    }
    $debug_message = sprintf('[%2.3f] %15s(%04s-%03s): %s%s: %s', $timer, basename($file), $line, $level, str_repeat('.', $indent), $method, substr($msg, 0, 200));
    if ($debug_file || $_SESSION[APPCONFIG]->getValue('debug', 'file')) {
        if (!$debug_file) {
            $debug_file = fopen($_SESSION[APPCONFIG]->getValue('debug', 'file'), $_SESSION[APPCONFIG]->getValue('debug', 'append') ? 'a' : 'w');
        }
        fwrite($debug_file, $debug_message . "\n");
    }
    if ($_SESSION[APPCONFIG]->getValue('debug', 'syslog') && function_exists('syslog_notice')) {
        syslog_notice($debug_message);
    }
}
Esempio n. 12
0
		FROM  uw_collection_contents, uw_collection
		WHERE uw_collection.collection_id=uw_collection_contents.collection_id
		AND uw_collection_contents.remove_transaction_id is NULL
		AND uw_collection.remove_transaction_id is NULL
		GROUP BY uw_collection.collection_id
	) AS counts
		ON spellings.id=counts.id
		ORDER BY spelling
" ) or die ( "error " . mysql_error() );



print "<ul>";
while ( $row = mysql_fetch_array( $result, MYSQL_NUM ) ) {
	$id = $row[0];
	$spelling = $row[1];
	$total = $row[2];
	print "<li><a href=\"collection.php?collection=$id\">$spelling</a> ($total defined meanings) </li>";
}
print "</ul>";

echo"<hr><div align=\"right\"><small>Page time: " . substr( ( stopwatch() - $start ), 0, 5 ) . " seconds</small></div>";
?>

<p align="left">
<h3> see also</h3>
<ul>
<li><a href="stats.php">Overview, expressions per language</a></li>
<li><a href="../../..">return to Omegawiki proper</li></a>
</p>
Esempio n. 13
0
// $Header: /cvsroot/phpldapadmin/phpldapadmin/lib/common.php,v 1.76.2.6 2005/12/30 02:32:41 wurley Exp $
/**
 * Contains code to be executed at the top of each phpLDAPadmin page.
 * include this file at the top of every PHP file.
 *
 * This file will "pre-initialise" a PLA environment so that any PHP file will have a consistent
 * environment with other PLA PHP files.
 *
 * This code WILL NOT check that all required functions are usable/readable, etc. This process has
 * been moved to index.php (which really is only called once when a browser hits PLA for the first time).
 *
 * The list of ADDITIONAL function files is now defined in functions.php.
 *
 * @package phpLDAPadmin
 */
$timer = stopwatch();
@define('LIBDIR', '../lib/');
# For PHP5 backward/forward compatibility
if (!defined('E_STRICT')) {
    define('E_STRICT', 2048);
}
# General functions needed to proceed.
ob_start();
require_once realpath(LIBDIR . 'functions.php');
ob_end_clean();
/* Our custom error handler receives all error notices that pass the error_reporting()
   level set above. */
set_error_handler('pla_error_handler');
# Disable error reporting until all our required functions are loaded.
error_reporting(0);
/*