<?php
set_time_limit(0);
//计时函数
function G($start,$end='',$dec=4)
{
static $_info = array();
if (!empty($end))
{
if(!isset($_info[$end])) $_info[$end] = microtime(TRUE);
$sconds = number_format(($_info[$end]-$_info[$start]), $dec) * 1000;
echo "{$sconds}ms<br />";
}
else
{
$_info[$start] = microtime(TRUE);
}
}
$redis = new Redis();
$redis->connect('127.0.0.1');
G('t');
$redis->pipeline();
for ($i=0; $i < 100000 ; $i++) {
$redis->set("test_{$i}", pow($i, 2));
$redis->get('test_{$i}');
}
$redis->exec();
G('t','r');
G('m');
$redis->multi();
for ($i=0; $i < 100000 ; $i++) {
$redis->set("test_{$i}", pow($i, 2));
$redis->get('test_{$i}');
}
$redis->exec();
G('m','i');
$redis->flushdb();
G('f');
for ($i=0; $i < 100000 ; $i++) {
$redis->set("test_{$i}", pow($i, 2));
$redis->get('test_{$i}');
}
G('f','e');
?>
PHP 统计执行时间
最新推荐文章于 2025-10-21 13:09:51 发布
1183

被折叠的 条评论
为什么被折叠?



