简体   繁体   English

HHVM上的session_start()函数比php5或php7慢

[英]session_start() function is very slower on HHVM than php5 or php7

for this simple code: 对于这个简单的代码:

<?php
$time_start = microtime(true);

session_start();
echo session_id();

$time_end = microtime(true);
$time = ($time_end - $time_start)*1000;
echo "<br> Time to get uid: $time milliseconds";

?>

When I run it in php7 or php5 with Apache server, the run time is around one millisecond but my machine with HHVM takes 60-100ms to execute this. 当我使用Apache服务器在php7或php5中运行它时,运行时间约为1毫秒,但是我的带有HHVM的计算机执行此操作需要60-100ms。 I tried changing the handler to Redis rather than files but got it more than 100ms. 我尝试将处理程序更改为Redis而不是文件,但超过了100ms。 I also tried deleting all other sessions, the same. 我也尝试删除所有其他会话,同样。 Any idea? 任何想法?

I figured out the problem. 我解决了这个问题。 In my own system the longer time is due to large variables I saved in my session, while a new session in other systems starts as an empty session. 在我自己的系统中,较长的时间是由于我在会话中保存的变量大而导致的,而其他系统中的新会话则从空会话开始。

For future reference, session_start() run-time depends on variables the system needs to load and make them available as a session; 供将来参考,session_start()的运行时取决于系统需要加载并使其可作为会话使用的变量。 so less data you put on your session the faster your overall page speed will be, if you're using sessions in your php code. 因此,如果您在php代码中使用会话,则您在会话中放置的数据越少,总体页面速度就会越快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM