本文整理汇总了PHP中unregister_tick_function函数的典型用法代码示例。如果您正苦于以下问题:PHP unregister_tick_function函数的具体用法?PHP unregister_tick_function怎么用?PHP unregister_tick_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unregister_tick_function函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __profiler__
function __profiler__($cmd = false)
{
static $log, $last_time, $total;
list($usec, $sec) = explode(" ", microtime());
$now = (double) $usec + (double) $sec;
if ($cmd) {
if ($cmd == 'get') {
unregister_tick_function('__profile__');
foreach ($log as $function => $time) {
if ($function != '__profile__') {
$by_function[$function] = round($time / $total * 100, 2);
}
}
arsort($by_function);
return $by_function;
} else {
if ($cmd == 'init') {
$last_time = $now;
return;
}
}
}
$delta = $now - $last_time;
$last_time = $now;
$trace = debug_backtrace();
$caller = $trace[1]['function'];
if (!isset($log[$caller])) {
$log[$caller] = 0;
}
// Aral: Added to remove undefined index errors.
@($log[$caller] += $delta);
$total += $delta;
}
示例2: stop
/**
* Stop profiler
*/
public function stop()
{
$this->_endTime = microtime(true);
$this->tick();
if (Sys::isFunc('unregister_tick_function')) {
unregister_tick_function(array($this, 'tick'));
}
}
示例3: stop
public function stop()
{
unregister_tick_function(array($this, "tick"));
$this->timeUsed = microtime(true) - $this->timeUsed;
if ($this->logFileHandler) {
fclose($this->logFileHandler);
}
}
示例4: stop
/**
* Stop
*/
public static function stop()
{
unregister_tick_function('alive_tick');
if (self::$ob_start) {
ob_start();
echo self::$buffer;
}
}
示例5: benchmarkMemory
/**
*
* @param callable $function A function to be measured
* @param array $args Parameters to be passed for measured function
* @return array Result currently contains one value: used memory space
*/
public function benchmarkMemory(callable $function, array $args = array())
{
declare (ticks=1);
$this->memory = memory_get_usage();
$this->max = 0;
register_tick_function('call_user_func', array($this, 'memoryTick'));
$this->measureFunction($function, $args, 1);
unregister_tick_function('call_user_func');
return array(self::MEMORY_VALUE => $this->max);
}
示例6: __appprofiler_ontick
public static function __appprofiler_ontick()
{
static $time, $ltrace, $tick;
$tick = (int) $tick + 1;
if ($tick == 10) {
$tick = 0;
$exec = round(microtime(true) - self::$tracestart, 2) . "sec";
$info = round(memory_get_usage(true) / 1024 / 1024, 2) . "MiB";
echo "7[0;60H[1;37;41m{$exec}/{$info}[0m8";
}
if (!$time) {
$time = microtime(true);
}
$trace = debug_backtrace(0, 2);
if (count($trace) < 2) {
$trace[1] = $trace[0];
}
if ($trace[1] == $ltrace[1]) {
return;
}
array_walk_recursive($trace[1], function (&$v, $k) {
if (is_object($v)) {
$v = "[object:" . get_class($v) . "]";
}
});
$ltrace = $trace;
if (count($trace) == 0) {
var_dump($trace);
}
$exe_time = (microtime(true) - $time) * 1000;
if (memory_get_usage(true) > 10000000) {
\debug("Memory usage > 10MB. Disabling profiling.");
unregister_tick_function("Cherry\\Util\\AppProfiler::__appprofiler_ontick");
}
$stats = array("current_time" => microtime(true) - self::$tracestart, "memory" => memory_get_usage(false), "ns" => $exe_time);
$stats = array_merge((array) $stats, (array) $trace[1]);
if (self::$binlog) {
self::$tracelog->write($stats);
} else {
fwrite(self::$tracelog, json_encode($stats) . "\n");
}
$time = microtime(true);
}
示例7: checkForDeclareDirective
private function checkForDeclareDirective()
{
// PHP7 appears to exhibit different behavior with ticks than
// 5. Basically, >=7 requires the tick handler at the top of this
// file for this to execute at all (making the detection
// pointless), but it doesn't persist in the rest of the script.
if (version_compare(\PHP_VERSION, '7.0.0', '>=')) {
return;
}
register_tick_function([$this, 'didTick']);
usleep(1);
if (!$this->didTick) {
// Try a bunch of no-ops in case the directive is set as > 1
$i = 1000;
while ($i--) {
}
}
unregister_tick_function([$this, 'didTick']);
if (!$this->didTick) {
fwrite(STDERR, "It looks like `declare(ticks=1);` has not been " . "called, so signals to stop the daemon will fail. Ensure " . "that the root-level script calls this.\n");
exit(1);
}
}
示例8: unregister_tick_function
<?php
unregister_tick_function('profile');
示例9: stopCounting
/**
* Stops counting
*
* @return void
*/
public function stopCounting()
{
\unregister_tick_function(array($this, "countSplit"));
}
示例10: declare
<?php
declare (ticks=1);
register_tick_function($closure = function () {
echo "Tick!\n";
});
unregister_tick_function($closure);
echo "done";
示例11: stop_profile
/**
* Stop profiling
* @access public
* @return void
*/
public static function stop_profile()
{
unregister_tick_function(array(__CLASS__, 'do_profile'));
}
示例12: bypass_suhosin
function bypass_suhosin($function, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $output_needed = True)
{
//I found no other way to deal with arguments... poor me.
if ($arg5 != null) {
if (disabled_php("call_user_func") == False) {
$return_value = call_user_func($function, $arg1, $arg2, $arg3, $arg4, $arg5);
} else {
if (disabled_php("call_user_func_array") == False) {
$return_value = call_user_func_array($function, array($arg1, $arg2, $arg3, $arg4, $arg5));
} else {
if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
$ref_function = new ReflectionFunction($function);
$handle = $ref_function->invoke($arg1, $arg2, $arg3, $arg4, $arg5);
if (is_string($handle)) {
$return_value = $handle;
} else {
$return_value = fread($handle, 4096);
pclose($handle);
}
} else {
if ($output_needed == False) {
if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
$it = new ArrayIterator(array(""));
iterator_apply($it, $function, array($arg1, $arg2, $arg3, $arg4, $arg5));
} else {
if (disabled_php("register_tick_function") == False) {
declare (ticks=1);
register_tick_function($function, $arg1, $arg2, $arg3, $arg4, $arg5);
unregister_tick_function($function);
} else {
if (disabled_php("array_map") == False) {
array_map($function, array($arg1, $arg2, $arg3, $arg4, $arg5));
} else {
if (disabled_php("array_walk") == False) {
$x = array($arg1, $arg2, $arg3, $arg4, $arg5);
array_walk($x, $function);
} else {
if (disabled_php("array_filter") == False) {
array_filter(array($arg1, $arg2, $arg3, $arg4, $arg5), $function);
} else {
if (disabled_php("register_shutdown_function")) {
register_shutdown_function($function, $arg1, $arg2, $arg3, $arg4, $arg5);
}
}
}
}
}
}
}
}
}
}
} else {
if ($arg4 != null) {
if (disabled_php("call_user_func") == False) {
$return_value = call_user_func($function, $arg1, $arg2, $arg3, $arg4);
} else {
if (disabled_php("call_user_func_array") == False) {
$return_value = call_user_func_array($function, array($arg1, $arg2, $arg3, $arg4));
} else {
if (version_compare(PHP_VERSION, '5.0.0') >= 0 && disabled_php(null, "ReflectionFunction") == False) {
$ref_function = new ReflectionFunction($function);
$handle = $ref_function->invoke($arg1, $arg2, $arg3, $arg4);
if (is_string($handle)) {
$return_value = $handle;
} else {
$return_value = fread($handle, 4096);
pclose($handle);
}
} else {
if ($output_needed == False) {
if (version_compare(PHP_VERSION, '5.1.0') >= 0 && disabled_php(null, "ArrayIterator") == False) {
$it = new ArrayIterator(array(""));
iterator_apply($it, $function, array($arg1, $arg2, $arg3, $arg4));
} else {
if (disabled_php("register_tick_function") == False) {
declare (ticks=1);
register_tick_function($function, $arg1, $arg2, $arg3, $arg4);
unregister_tick_function($function);
} else {
if (disabled_php("array_map") == False) {
array_map($function, array($arg1, $arg2, $arg3, $arg4));
} else {
if (disabled_php("array_walk") == False) {
$x = array($arg1, $arg2, $arg3, $arg4);
array_walk($x, $function);
} else {
if (disabled_php("array_filter") == False) {
array_filter(array($arg1, $arg2, $arg3, $arg4), $function);
} else {
if (disabled_php("register_shutdown_function")) {
register_shutdown_function($function, $arg1, $arg2, $arg3, $arg4);
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例13: setup_ticks
/**
* Appologies for the commented code.
* I would like to restore this functionality eventually.
* this is supposed to verify that ticks is a small enough number, as required
* by pnctl to fork and manage signals but that static var manipulation doesn't
* work from PHP7 so we'll disable for now
*/
private function setup_ticks()
{
$tick_f = function () {
ForkManager::confirmTicks();
};
register_tick_function($tick_f);
// This is a short NOP+microsleep, just to
// give verify_declare_ticks() a change to verify.
$i = 0;
$i++;
$i++;
$i++;
time_nanosleep(0, 5000);
if (self::$have_ticks) {
unregister_tick_function($tick_f);
} else {
die("FM requires a 'declare(ticks=1);' in the calling code.\n");
}
}
示例14: start
/**
* Starts the thread.
* @return bool On successful execution returns true otherwise returns false.
*/
public final function start()
{
// {{{
if (!$this->amIParent()) {
return false;
}
if ($this->amIStarted) {
return false;
}
$this->childPid = pcntl_fork();
if ($this->childPid == -1) {
return false;
}
$this->_childPid = getmypid();
$this->amIStarted = true;
$csInitializationResult = null;
if ($this->criticalSection !== null) {
$csInitializationResult = $this->criticalSection->initialize($this->childPid, $this->uniqueId);
}
if (!$this->amIParent()) {
// child
// no dispatchers needed in the children; this means that no threads withing threads creation is possible
unregister_tick_function('GPhpThreadCriticalSection::dispatch');
// flag any subscribed variables indicating that the current
// instance is located in a GPhpThread
foreach (self::$originDynamicDataArr as &$o) {
if ($o instanceof \GPhpThreadNotCloneableContainer) {
$o->import(true);
}
}
if ($csInitializationResult === false) {
$this->stop();
}
// don't execute the thread body if critical section is required, but missing
pcntl_sigprocmask(SIG_UNBLOCK, array(SIGCHLD));
$this->run();
if ($this->criticalSection !== null) {
$this->notifyParentThatChildIsTerminated();
}
$this->stop();
} else {
// parent
if ($this->childPid != -1 && $this->criticalSection !== null) {
if ($csInitializationResult === false) {
// don't add the thread to the dispatch queue if missing but required critical section is the case (actually this is done in the initialize method above)
$this->childPid = -1;
$this->_childPid = null;
$this->amIStarted = false;
return false;
}
if (!GPhpThread::$isCriticalSectionDispatcherRegistered) {
GPhpThread::$isCriticalSectionDispatcherRegistered = register_tick_function('GPhpThreadCriticalSection::dispatch');
}
pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD));
// SIGCHLD will wait in the queue until it's processed
}
return true;
}
return true;
}
示例15: jse_run
function jse_run($flags = JSE_ACCEL)
{
// interrupt every 1000 low-level statements
if ($flags & JSE_TICKS) {
register_tick_function(array("jsrt", "tick_safe"));
declare (ticks=1000);
}
#-- check for accelerator/assembler presence
if ($flags & JSE_ACCEL && class_exists("jsa") && class_exists("jsrt")) {
eval(jsa::assemble(NULL, $flags & JSE_TICKS));
} else {
jsi::run();
}
#-- clean up
if ($flags & JSE_TICKS) {
unregister_tick_function(array("jsrt", "tick_safe"));
declare (ticks=0);
}
}