当前位置: 首页>>代码示例>>PHP>>正文


PHP unregister_tick_function函数代码示例

本文整理汇总了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;
}
开发者ID:hafizubikm,项目名称:bakeme,代码行数:33,代码来源:Profiler.php

示例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'));
     }
 }
开发者ID:jbzoo,项目名称:profiler,代码行数:11,代码来源:Profiler.php

示例3: stop

 public function stop()
 {
     unregister_tick_function(array($this, "tick"));
     $this->timeUsed = microtime(true) - $this->timeUsed;
     if ($this->logFileHandler) {
         fclose($this->logFileHandler);
     }
 }
开发者ID:yegortokmakov,项目名称:phprtest,代码行数:8,代码来源:Profiler.php

示例4: stop

 /**
  * Stop
  */
 public static function stop()
 {
     unregister_tick_function('alive_tick');
     if (self::$ob_start) {
         ob_start();
         echo self::$buffer;
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:11,代码来源:alive.php

示例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);
 }
开发者ID:almadomundo,项目名称:benchmark,代码行数:16,代码来源:Measure.php

示例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);
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:43,代码来源:appprofiler.php

示例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);
     }
 }
开发者ID:firehed,项目名称:processmanager,代码行数:23,代码来源:Daemon.php

示例8: unregister_tick_function

<?php

unregister_tick_function('profile');
开发者ID:zmwebdev,项目名称:PHPcookbook-code-3ed,代码行数:3,代码来源:timing-program6.php

示例9: stopCounting

 /**
  * Stops counting
  *
  * @return void
  */
 public function stopCounting()
 {
     \unregister_tick_function(array($this, "countSplit"));
 }
开发者ID:malkusch,项目名称:php-index,代码行数:9,代码来源:SplitCounter.php

示例10: declare

<?php

declare (ticks=1);
register_tick_function($closure = function () {
    echo "Tick!\n";
});
unregister_tick_function($closure);
echo "done";
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:bug66094.php

示例11: stop_profile

 /**
  * Stop profiling
  * @access public
  * @return void
  */
 public static function stop_profile()
 {
     unregister_tick_function(array(__CLASS__, 'do_profile'));
 }
开发者ID:kkelly51,项目名称:Mycodo,代码行数:9,代码来源:SimpleProfiler.php

示例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);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
//.........这里部分代码省略.........
开发者ID:danny4you2,项目名称:DAws,代码行数:101,代码来源:DAws.php

示例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");
     }
 }
开发者ID:centraldesktop,项目名称:parallel,代码行数:26,代码来源:ForkManager.php

示例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;
 }
开发者ID:zhgzhg,项目名称:gphpthread,代码行数:64,代码来源:GPhpThread.php

示例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);
    }
}
开发者ID:slajax,项目名称:Mojo-Tasks,代码行数:19,代码来源:js.php


注:本文中的unregister_tick_function函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。