cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[BUG]: getTotalElapsedSeconds() - too many seconds

Open zak-wojtek77 opened this issue 4 years ago • 10 comments

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

zak-wojtek77 avatar Dec 07 '21 09:12 zak-wojtek77

/cc @niden I think this was already fixed.

Jeckerson avatar Dec 07 '21 16:12 Jeckerson

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?

niden avatar Dec 17 '21 18:12 niden

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.

zak-wojtek77 avatar Dec 20 '21 07:12 zak-wojtek77

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

satorumoriwaki avatar Apr 15 '22 03:04 satorumoriwaki

This won't be fixed in v4, please upgrade to v5. Closing.

Jeckerson avatar Oct 26 '22 17:10 Jeckerson

I have installed Phalcon 5.1.1 and this problem still exists.

zak-wojtek77 avatar Nov 30 '22 12:11 zak-wojtek77

@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.

niden avatar Nov 30 '22 14:11 niden

Thank you for info.

zak-wojtek77 avatar Nov 30 '22 14:11 zak-wojtek77

Resolved in https://github.com/phalcon/cphalcon/pull/16234

niden avatar Nov 30 '22 17:11 niden

I have installed Phalcon 5.1.2 and now is OK.

zak-wojtek77 avatar Dec 01 '22 07:12 zak-wojtek77