php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44839 custom timer class gives incorrect time with sleep(1);
Submitted: 2008-04-26 10:48 UTC Modified: 2008-04-26 19:17 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kjarli at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.5 OS: windows xp media center
Private report: No CVE-ID: None
 [2008-04-26 10:48 UTC] kjarli at gmail dot com
Description:
------------
When I tried to benchmark my type casting tests, I found out I was getting very, very low numbers. So I added sleep(1);
The result was nothing I expected.

Reproduce code:
---------------
All needed provided in: http://pastebin.org/32109

Expected result:
----------------
To see a time of about 1.00[0-9]* seconds.

Actual result:
--------------
about 90% of the time, the number of seconds is 0.999[0-9]*

Very wierd since I used sleep(1);

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-26 19:17 UTC] jani@php.net
Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is, read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 26 06:00:03 2025 UTC