public static function hook() { //打包全部hook $hooks = array(); $modules = zotop::data('module'); foreach ($modules as $module) { $path = $module['path'] . DS . 'hook'; $path = path::decode($path); $hook = (array) dir::files($path, '', true, true); $hooks = array_merge($hooks, $hook); } $content = runtime::compile($hooks); if (!empty($content)) { file::write(ZPATH_RUNTIME . DS . 'hook.php', $content, true); } }
/** * 运行时执行,并加载相关文件 */ public static function run() { //打包配置文件 zotop::data(ZOTOP_PATH_RUNTIME . DS . 'config.php', zotop::config()); //打包全部hook文件 $hooks = runtime::compile(runtime::$hooks); if (!empty($hooks)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '_hooks.php', $hooks, true); } //加载hooks以便核心文件使用 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '_hooks.php'); //打包核心文件 $libraries = zotop::register(); $libraries = runtime::compile($libraries); if (!empty($libraries)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APP_NAME . '.php', $libraries, true); } }
/** * 运行时执行,并加载相关文件 */ public static function build() { runtime::config(); runtime::library(); runtime::hooks(); //打包配置文件 zotop::data(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.config.php', zotop::config()); //打包全部hook文件 $hooks = runtime::compile(runtime::$hooks); if (!empty($hooks)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.hooks.php', $hooks, true); } //加载hooks以便核心文件使用 zotop::load(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.hooks.php'); //打包核心文件 $libraries = zotop::register(); $libraries = runtime::compile($libraries); if (!empty($libraries)) { file::write(ZOTOP_PATH_RUNTIME . DS . ZOTOP_APPLICATION_GROUP . '.core.php', $libraries, true); } }
} function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round($this->StopTime - $this->StartTime, 1); } } //例子 $runtime = new runtime(); $runtime->start(); //////////////////////////////////////////////////////////// ?> <!--STATUS OK--><html><head> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <title><?php echo $config["name"]; ?> 搜索_<?php echo $wd . $config["adtitle"]; ?> </title> <link rel="stylesheet" href="images/css.css" type="text/css"> <script language="javascript" src="global.js"></script></head> <body link="#261CDC">
} function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } //消耗时间 $runtime = new runtime(); $runtime->start(); // 下载 if (!isset($_POST['submit'])) { die; } $destination_folder = $Folder; if (!is_dir($destination_folder)) { mkdir($destination_folder, 0777); } $url = $_POST['url']; $file = fopen($url, "rb"); if ($file) { // 获取文件大小 $filesize = -1; $headers = get_headers($url, 1);
return (double) $usec + (double) $sec; } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } $runtime = new runtime(); $runtime->start(); //error_log(var_export($_POST,true)); $start = time(); if (!empty($_POST['text']) && !empty($_POST['lang']) && !empty($_POST['newsid'])) { $text = trim(urldecode($_POST['text'])); $infile = $_POST['newsid']; $filepath = "./sound/"; file_put_contents($filepath . $infile, $text); $lang = urldecode($_POST['lang']); //error_log("info:".$_POST["newsid"]." ".$lang." \n".$text." \n"); $langtype = "Kyoko"; switch ($lang) { case "cn": $langtype = "Ting-Ting"; break;
return (double) $usec + (double) $sec; } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } $runtime = new runtime(); $runtime->start(); if (!isset($_POST['submit'])) { die; } $destination_folder = './'; // 下載的檔保存目錄。必須以斜杠結尾 if (!is_dir($destination_folder)) { //判斷目錄是否存在 mkdir($destination_folder, 0777); } //若無則創建,並給與777許可權 windows忽略 $url = $_POST['url']; $headers = get_headers($url, 1); //得到檔大小 if (!array_key_exists("Content-Length", $headers)) {
{ return $this->redis->get($this->expire); } /** * * 错误提示 * @param string $msg */ public function warn($msg) { die($msg . "\n"); } } $l = new CacheList("testList", "id"); $l->delList(); $runtime = new runtime(); $list = $list1 = array(); //100条数据 for ($i = 100; $i <= 200; $i++) { $list[] = array("id" => $i, "V" => "V" . $i); } for ($i = 200; $i <= 1200; $i++) { $list1[] = array("id" => $i, "V" => "V" . $i); } $runtime->start(); $l->addList($list, 100); $runtime->stop(); echo "insert total : " . $runtime->spent() . "ms\n"; $runtime->start(); $ol = $l->getList(0, 100); $runtime->stop();
function test_foreach_array() { global $cfg; $run_3 = new runtime(); $run_3->start(); $my = new foreach_array($cfg); $run_3->stop(); echo "size: ", print_r($my->cal_size()); echo "\nspent: " . $run_3->spent() . "\n"; }
var $StartTime = 0; var $StopTime = 0; function get_microtime() { list($usec, $sec) = explode(' ', microtime()); return (double) $usec + (double) $sec; } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } //例子 $runtime = new runtime(); $runtime->start(); //你的代码开始 $a = 0; for ($i = 0; $i < 1000000; $i++) { $a += $i; } //你的代码结束 $runtime->stop(); echo '<align="right">页面执行时间: ' . $runtime->spent() . ' 毫秒</align>';
/** * @param int $timeout * @param mixed $resolve * * @return \generator */ public static function delay(int $timeout, $resolve = null) : \generator { $timeout = self::ms2s($timeout); yield from self::wait(microtime(true), $timeout); return runtime::await($resolve); }
} function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(0.015 * $this->StopTime - 0.015 * $this->StartTime, 3); } } //例子 $runtime = new runtime(); $runtime->start(); //////////////////////////////////////////////////////////// ?> <!--STATUS OK--> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title><?php echo $config["adtitle"]; ?> _<?php echo $wd; ?> </title> <link rel="stylesheet" href="images/css.css" type="text/css"> <link rel="stylesheet" href="images/style.css" type="text/css">
} function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round($this->StopTime - $this->StartTime, 1); } } //例子 $runtime = new runtime(); $runtime->start(); ?> <!--STATUS OK--> <html> <head> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <title><?php echo $config["name"]; ?> 搜索_<?php echo $wd . $config["adtitle"]; ?> </title> <link rel="stylesheet" href="images/css.css" type="text/css"> <script language="javascript" src="global.js"></script></head>
<?php define("SITE_ROOT", '/web/dnasys.isoshu.com'); include '../config/core.php'; // test app runtime include LIB . "/runtime.class.php"; $runtime = new runtime(); $runtime->start(); include '../module/index.php'; $runtime->stop(); echo "\n<!-- the page cost " . $runtime->spent() . " ms -->\n";
<?php $runtime = new runtime(); $runtime->start(); class runtime { var $StartTime = 0; var $StopTime = 0; function get_microtime() { list($usec, $sec) = explode(' ', microtime()); return (double) $usec + (double) $sec; } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } header("content-Type: text/html; charset=utf-8"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); $sysReShow = false !== ($sysInfo = sysInfo()) ? "show" : "none"; function sysInfo()
return (double) $usec + (double) $sec; } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } $runtime = new runtime(); $runtime->start(); $a = 0; for ($i = 0; $i < 1000000; $i++) { $a += $i; } $runtime->stop(); $time = '执行时间: ' . $runtime->spent() . ' 毫秒'; //appkey //452d3958f048c02a 12737ff7776f1ade | 85eb6835b0a1034e 876fe0ebd0e67a0f 95acd7f6cc3392f3 ed77450d77370a3d 03fc8eb101b091fb ?> <span class="info1"> 视频标题:<?php echo $title; ?> <br />
<?php /** * Created by IntelliJ IDEA. * User: lihuanpeng * Date: 15/8/27 * Time: 21:59 * 多进程下载测试 */ include '../function/function.php'; include '../library/simplehtmldom/simple_html_dom.php'; include '../library/runtime.class.php'; // 计算某段代码耗时 $runtime = new runtime(); $img_urls = ["http://s4.ihostimg.com/s4/20150823202814fuq4t.jpeg", "http://s4.ihostimg.com/s4/20150823202819rb8zv.jpeg", "http://s4.ihostimg.com/s4/20150823202823ghyic.jpeg", "http://s4.ihostimg.com/s4/20150823202828dj9dq.jpeg", "http://s4.ihostimg.com/s4/201508232028320u5sd.jpeg", "http://s4.ihostimg.com/s4/20150823202841aga9k.jpeg", "http://s4.ihostimg.com/s4/20150823202849ol12p.jpeg", "http://s4.ihostimg.com/s4/20150823202858wahlm.jpeg", "http://s4.ihostimg.com/s4/20150823202906gf5gp.jpeg", "http://s4.ihostimg.com/s4/201508232029105qa8c.jpeg", "http://s4.ihostimg.com/s4/20150823202923vnn71.jpeg", "http://s4.ihostimg.com/s4/20150823202930n446h.jpeg", "http://s4.ihostimg.com/s4/20150823202939pi11f.jpeg", "http://s4.ihostimg.com/s4/20150823202951o5bp5.jpeg", "http://s4.ihostimg.com/s4/20150823203003yq3ek.jpeg"]; $url_quantity = count($img_urls); $workers = 3; $pids = array(); for ($i = 0; $i < $workers; $i++) { $pids[$i] = pcntl_fork(); // 创建子进程 switch ($pids[$i]) { case -1: alert('创建子进程失败:' . $i); exit; case 0: $key_start = $url_quantity / $workers * $i; $key_end = $url_quantity / $workers * ($i + 1); for ($j = $key_start; $j < $key_end; $j++) { $img_name = basename($img_urls[$j]); $file = "../caoliu/download/" . $img_name;
} function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 1); } } //例子 $runtime = new runtime(); $runtime->start(); require_once dirname(__FILE__) . "/../../include/common.inc.php"; $dsql->safeCheck = FALSE; $nidurl = ""; $autosql = ""; $page = $_GET['page'] + 1; if (isset($_GET['nid'])) { if (strstr($_GET['nid'], ",")) { $autosql = "and typeid>0 "; } $row = $dsql->getone("SELECT * FROM `#@__co_note` where nid in (" . $_GET['nid'] . ") " . $autosql . "order by cotime"); //循环采集特定的规则 if (!is_array($row)) { echo "没有符合条件的采集规则,请检查您的设置!"; exit;
return (double) $usec + (double) $sec; } function start() { $this->StartTime = $this->get_microtime(); } function stop() { $this->StopTime = $this->get_microtime(); } function spent() { return round(($this->StopTime - $this->StartTime) * 1000, 2); } } //example $runtime = new runtime(); $runtime->start(); /*============coding-start==========*/ $a = 0; for ($i = 0; $i < 1000000; $i++) { $a += $i; } // echo time(); // echo $_SERVER['REQUEST_TIME']; /*============coding-end=================*/ $runtime->stop(); echo "Page execution time: " . $runtime->spent() . " Millisecond"; ?>
<?php $runtime = new runtime(); //开始计时类 $runtime->start(); //计时 //设置时区,当前为北京时间 date_default_timezone_set('PRC'); //error_reporting(E_ALL ^ E_NOTICE);//不提示NOTICE消息 error_reporting(E_ALL); //提示所有消息 /** 论坛数据库的名称 */ define('DB_NAME', 'zxtd'); /** MySQL 数据库用户名 */ define('DB_USER', 'root'); /** MySQL 数据库密码 */ define('DB_PASSWORD', '123456'); /** MySQL 主机 */ define('DB_HOST', 'localhost'); /** 创建数据表时默认的文字编码 */ define('DB_CHARSET', 'utf8'); /** 数据库前缀 */ define('MYSQL_PR', 'zx_'); /** 密码KEY */ define('PASSWORD_KEY', '&Ku4nWtf$V0xu^y*zfu4StTfjJQyYG8j'); /** cookie前缀 */ define('COOKIE_PR', 'ZXTD_'); define('HTML_CHARSET', 'UTF-8'); //网页编码 //临时开启全部发送编码头文件 header("content-Type: text/html; charset=" . HTML_CHARSET . "");