$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;
                // 下载图片
                $runtime->start();
                $opts = ['http' => ['method' => 'GET', 'header' => "Accept-language: en\r\n" . "Referer: " . $img_urls[$j] . "\r\n"]];
                $context = stream_context_create($opts);
                $data = file_get_contents($img_urls[$j], false, $context);
                file_put_contents($file, $data);
                $runtime->stop();
                if (file_exists($file)) {
                    alert('[' . $img_name . '] ' . '下载成功,' . '耗时:' . $runtime->spent() . '秒');
                }
            }
            exit;
        default:
            break;
    }
}
Exemple #2
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>';
Exemple #3
0
echo $config["url"];
?>
')" href="#" style="color:#000000 ">把<?php 
echo $config["name"];
?>
设为主页</a></td>
<td align="right" nowrap><?php 
echo $config["name"];
?>
一下,找到相关网站约<?php 
echo $total;
?>
个,
<?php 
$runtime->stop();
echo "页面执行时间: " . $runtime->spent() . " 秒";
?>
&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<?php 
RightAd();
?>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
<?php 
if ($total > 0) {
    foreach ($data as $link) {
        ?>
<table border="0" cellpadding="0" cellspacing="0" id="1"><tr><td class=f>
Exemple #4
0
    {
        $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 />
Up主:<?php 
echo $up;
?>
</span>
<span class="info2">
视频信息:aid:<?php 
echo $aid;
            $langtype = "Kathy";
            break;
        case "jp":
            $langtype = "Kyoko";
            break;
        default:
            $langtype = "Kyoko";
    }
    //run del
    system("say -o " . $filepath . $infile . "out.mp4 -v {$langtype} -f " . $filepath . $infile);
    //error_log("say -o ".$filepath.$infile."out.mp4 -v $langtype -f ".$filepath.$infile);
    /* File Read */
    $filename = $infile . "out.mp4";
    if (!file_exists($filepath . $filename)) {
        echo $filepath . $filename . "  not exist!";
        error_log($filepath . $filename . "  not exist!");
    } else {
        header('Content-Type:application/octet-stream');
        header('Content-Disposition:attachment; filename="' . basename($filename) . '"');
        header("Accept-Ranges: bytes");
        header('Accept-Length: ' . filesize($filepath . $filename));
        $file = fopen($filepath . $filename, 'r');
        echo fread($file, filesize($filepath . $filename));
        fclose($file);
        $runtime->stop();
        error_log("ok.." . $_POST["newsid"] . "   time(ms):" . $runtime->spent());
        exit;
    }
} else {
    error_log("---------params is empty:" . var_export($_POST, true));
}
Exemple #6
0
                //在前台显示已经下载文件大小
                ob_flush();
                flush();
            }
        }
    }
    if ($file) {
        fclose($file);
    }
    if ($newf) {
        fclose($newf);
    }
    $runtime->stop();
    //停止计算
    //乱七八糟的东西 -0-;
    $downtime = '<p>' . $Language[2] . ':<font color="blue"> ' . $runtime->spent() . ' </font>' . $Language[3] . '<font color="blue"> ' . $headers["Content-Length"] . ' </font>' . $Language[4] . '.</p><br>';
    $downok = '<p><font color="red">' . $Language[5] . '!' . date("Y-m-d H:i:s") . '</font></p><br>';
} elseif (isset($_POST['password'])) {
    $passerror = $Language[6] . '!' . $Language[7];
    echo "<script>alert('" . $passerror . "')</script>";
}
//$Export = $downtime.$downok.$passerror;
if (isset($_POST['url']) && $_POST['password'] == $password) {
    $filename = $Archives;
    $somecontent = $Language[11] . ': ' . $url . "\r\n" . $Language[2] . ": " . $runtime->spent() . $Language[3] . ": " . $headers["Content-Length"] . $Language[4] . "\r\n" . $Language[12] . ': ' . date("Y-m-d H:i:s") . "\r\n" . "\r\n";
    if (!file_exists($filename)) {
        $echo_1 = $Language[18];
        if (!fopen($filename, 'w')) {
            $echo_2 = $Language[19];
        }
    }
Exemple #7
0
        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();
echo "get total : " . $runtime->spent() . "ms\n";
//1000数据
$runtime->start();
$l->addList($list1, 100);
$runtime->stop();
echo "insert total : " . $runtime->spent() . "ms\n";
$runtime->start();
$ol = $l->getList(0, 1000);
$runtime->stop();
echo "get total : " . $runtime->spent() . "ms\n";
Exemple #8
0
    $headers = get_headers($url, 1);
    //得到檔大小
    if (!array_key_exists("Content-Length", $headers)) {
        $filesize = 0;
    }
    $newfname = $destination_folder . basename($url);
    $file = fopen($url, "rb");
    if ($file) {
        $newf = fopen($newfname, "wb");
        if ($newf) {
            while (!feof($file)) {
                fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
            }
        }
    }
    if ($file) {
        fclose($file);
    }
    if ($newf) {
        fclose($newf);
    }
    $runtime->stop();
    echo '<br /><li>下載耗時:<font color="blue"> ' . $runtime->spent() . ' </font>微秒,文件大小<font color="blue"> ' . $headers["Content-Length"] . ' </font>位元組</li>';
    echo '<br /><li><font color="red">下載成功! ' . ($showtime = date("Y-m-d H:i:s") . '</font></li>');
} elseif (isset($_POST['password'])) {
    echo '<br /><li><font color="red">密碼錯誤!請從新輸入密碼!</font></li>';
}
?>
</body>
</html>
Exemple #9
0
                            $renid = str_replace('-2', '-1', $renid);
                            if (strstr($notename, '+')) {
                                $nidtype = "+";
                            } else {
                                $nidtype = "-";
                            }
                            $rowlist = explode($nidtype, $notename);
                            $addnotename = $rowlist[0] . "-" . $endrow['typename'];
                            $co_note = "{dede:batchrule}" . $addco_note . "{/dede:batchrule}";
                            $listconfig1 = str_replace($notename, $addnotename, str_replace(substr($listconfig, stripos($listconfig, '{dede:batchrule}'), stripos($listconfig, '{/dede:batchrule}') - stripos($listconfig, '{dede:batchrule}') + 17), $co_note, $listconfig));
                            $cosql = " INSERT INTO `#@__co_note`(`channelid`,`notename`,`sourcelang`,`uptime`,`cotime`,`pnum`,`isok`,`listconfig`,`itemconfig`,`usemore`,booksum,renid,typeid)\r\n\t\t\t\t\t\t\t   VALUES ('1','{$addnotename}','{$sourcelang}','" . time() . "','0','0','1','{$listconfig1}','{$itemconfig}','1','1','{$renid}','1'); ";
                            if ($dsql->ExecuteNoneQuery($cosql)) {
                                $cnid = $dsql->GetLastID();
                                $dsql->ExecuteNoneQuery("update `#@__arctype` set copynid='{$cnid}' where id='" . $tidarr[1][$a] . "' ");
                                echo '处理完毕<br/>';
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    echo "没有符合条件的采集规则,请检查您的设置!<br />";
}
$runtime->stop();
if (isset($_GET['page'])) {
    echo "页面执行时间: " . $runtime->spent() . " 毫秒(" . date("Y-m-d H:i:s", time() + 1) . ")<br />";
} else {
    $co_time = 3;
}
Exemple #10
0
        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";
?>
 
Exemple #11
0
<td nowrap>&nbsp;&nbsp;&nbsp;<a onClick="h(this,'<?php 
echo $config["url"];
?>
')" href="#" style="color:#000000 ">把<?php 
echo $config["name"];
?>
设为主页</a></td>
<td align="right" nowrap><?php 
echo $config["name"];
?>
一下,找到相关网页约<?php 
echo $total;
?>
篇,<?php 
$runtime->stop();
echo "(用时: " . $runtime->spent() . "秒)";
?>
&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<p class="f14 f14 STYLE16"><strong>分类导航:</strong>
  <?php 
$result = $db->query("select * from ve123_fenlei order by about_id desc");
while ($rs = $db->fetch_array($result)) {
    ?>
  <a href="<?php 
    echo $config["url"];
    ?>
/list/?<?php 
    echo stripslashes($rs["urlid"]);
    ?>
Exemple #12
0
echo $config["url"];
?>
')" href="#" style="color:#000000 ">把<?php 
echo $config["name"];
?>
设为主页</a></td>
<td align="right" nowrap><?php 
echo $config["name"];
?>
一下,找到相关网页约<?php 
echo $total;
?>
篇,
<?php 
$runtime->stop();
echo "用时" . $runtime->spent() . " 秒";
?>
&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<?php 
RightAd();
if ($total > 0) {
    foreach ($data as $link) {
        ?>
<table border="0" cellpadding="0" cellspacing="0" id="1"><tr><td class=f>
            <?php 
        if ($link["is_tg"] == true) {
            ?>
<div class="a_d">
<?php 
Exemple #13
0
<?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";
Exemple #14
0
system("/bin/df -i | grep \"" . $disk . "\" | awk -F'/dev/' '{print \$2}' | awk '{print \"Inode已用: \"\$3}'");
system("/bin/df -i | grep \"" . $disk . "\" | awk -F'/dev/' '{print \$2}' | awk '{print \"Inode可用: \"\$4}'");
system("/bin/df -i | grep \"" . $disk . "\" | awk -F'/dev/' '{print \$2}' | awk '{print \"Inode已用比例: \"\$5}'");
echo "<br/>\n";
system("/usr/bin/free -m | grep Mem | awk '{print \"Mem共有: \"\$2\"MB\"}'");
system("/usr/bin/free -m | grep Mem | awk '{print \"Mem已使用: \"\$3\"MB\"}'");
system("/usr/bin/free -m | grep Mem | awk '{print \"Buffers化內存: \"\$6\"MB\"}'");
system("/usr/bin/free -m | grep Mem | awk '{print \"Cached化內存: \"\$7\"MB\"}'");
system("/usr/bin/free -m | grep Mem | awk '{print \"Mem空閒: \"\$4\"MB\"}'");
system("/usr/bin/free -m | grep buffers/cache: | awk '{print \"Men實際已用: \"\$3\"MB\"}'");
system("/usr/bin/free -m | grep buffers/cache: | awk '{print \"Mem實際空閒: \"\$4\"MB\"}'");
echo "<br/>\n";
system("/usr/bin/free | grep Swap | awk '{print \"Swap共有: \"\$2/1024\"MB\"}'");
system("/usr/bin/free | grep Swap | awk '{print \"Swap已用: \"\$3/1024\"MB\"}'");
system("/usr/bin/free | grep Swap | awk '{print \"Swap空閒: \"\$4/1024\"MB\"}'");
echo "<br/>\n";
system("/bin/cat /proc/net/dev | grep \"" . $net . "\" | awk -F'" . $net . "' '{print \$2}' | awk '{print \"已接收: \"\$1/1024/1024\"MB\"}'");
system("/bin/cat /proc/net/dev | grep \"" . $net . "\" | awk -F'" . $net . "' '{print \$2}' | awk '{print \"已發送: \"\$9/1024/1024\"MB\"}'");
echo "<br/>\n";
system('netstat -n | awk \'/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}\'');
echo "<br/>\n";
system('netstat -ntu | awk \'{print $5}\' | egrep -o "[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}" | sort | uniq -c | sort -nr');
echo "<br/>\n";
system("/bin/date");
echo "<br/>\n";
$runtime->stop();
echo "頁面執行時間: " . $runtime->spent() . " 毫秒";
echo '</pre>';
?>
</body>
</html>
Exemple #15
0
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";
}