我一直在尝试测量我的一个php函数在使用结果缓存和不使用结果缓存时所花费的时间。
我遇到了麻烦,因为无论谁先运行结果都会给我更多的时间,因此结果不是决定性的。
这是我的代码的一部分-
/**
*
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// $this->withoutCache($output);
$this->withCache($output);
$this->withoutCache($output);
}输出-
RUN 1 -
withoutCache: 0.10952067375183
withCache: 0.077319145202637
RUN 2 -
withCache: 0.17031812667847
withoutCache: 0.042220115661621我正在使用symfony框架,我正在测试在每次查询的情况下使用缓存是否对我有很大的帮助。Symfony使用Doctrine ORM和redis作为结果缓存。
发布于 2016-06-22 12:44:51
你可能正在初始化一些对象,或者做一些与实际进程无关的工作,这就是为什么第一个总是需要更多的时间。
在做基准测试之前。
希望这能有所帮助
https://stackoverflow.com/questions/37958064
复制相似问题