[BUG]: getTotalElapsedSeconds() - too many seconds
Describe the bug Function "getTotalElapsedSeconds()" return too many seconds. https://docs.phalcon.io/4.0/pl-pl/db-models-events#profiling-sql-statements
To Reproduce
// do any query to database
$result = $container->get('db')->query('select 1');
$result->fetch();
// get profiles
$profiles = $container->get('profiler')->getProfiles();
foreach ($profiles as $profile) {
var_dump($profile->getTotalElapsedSeconds());
}
Expected behavior It should be less than 1 second, show 221907 seconds.
Details
- Phalcon version: 4.1.2
- PHP Version: 7.4
- Operating System: Debian SID
- Installation type: Compiling from source
- Zephir version (if any):
- Server: Nginx
- Other related info (Database, table schema): MariaDB
Additional context This problem does not exist in Phalcon 4.0.6
/cc @niden I think this was already fixed.
I believe we fixed this already with https://github.com/phalcon/cphalcon/issues/15249
If possible can you install v5 and check if all is OK?
I cannot install Phalcon-5.0.0alpha7. I have any error during compilation. Second in my company I would like install only more stable Phalcon like 4.1.2. The best option for me would be if you release new version of Phalcon 4 with this bug. Thank you.
This needs to be fixed for 4.1.x because the microtime() and the hrtime() return different values.
$startMicro = microtime(true);
$startNano = hrtime(true);
// wait for 5 seconds
sleep(5);
echo 'microtime: ' . (microtime(true) - $startMicro);
echo 'hrtime: ' . (hrtime(true) - $startNano);
microtime: 5.0255100727081
hrtime: 5031415000
Phalcon 4.0.x uses microtime() only. https://github.com/phalcon/cphalcon/blob/4.0.x/phalcon/Db/Profiler.zep#L150
Phalcon 4.1.x uses both microtime() and hrtime(). https://github.com/phalcon/cphalcon/blob/4.1.x/phalcon/Db/Profiler.zep#L155-L159
Phalcon 5 uses hrtime() only. https://github.com/phalcon/cphalcon/blob/master/phalcon/Db/Profiler.zep#L150
This won't be fixed in v4, please upgrade to v5. Closing.
I have installed Phalcon 5.1.1 and this problem still exists.
@zak-wojtek77 Thank you for this. For some reason the commits from https://github.com/phalcon/cphalcon/issues/15249 never made it to the 5.0.x branch :/
Issuing a PR shortly to get this sorted out.
Thank you for info.
Resolved in https://github.com/phalcon/cphalcon/pull/16234
I have installed Phalcon 5.1.2 and now is OK.