|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9094 Microseconds seem to be untrue values
Submitted: 2001-02-03 20:24 UTC Modified: 2001-04-27 20:30 UTC
From: rue at 2rue dot de Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.0.4pl1 OS: MS Windows 2000
Private report: No CVE-ID: None
 [2001-02-03 20:24 UTC] rue at 2rue dot de
I wanted to measure script execution time, using microtime(). So I store a value at the beginning of the script, and one near the end, and subtract first from the second value (after converting).
And sometimes (i.e. on an irregular basis, maybe every 3rd or 4th try), the result is negative.
I mean, my scripts may be fast, but surely not *that* fast :-)

Here the relevant snippet:
// start marker
$mt = explode(' ', microtime() );
$benchmark1 = $mt[1] . substr($mt[0], 1);

// some code
// ...

// end marker
$mt2 = explode(' ', microtime() );
$benchmark2 = $mt2[1] . substr($mt2[0], 1);

$extime = $benchmark2 - $benchmark1;
// this alternative did the same:
// $extime = bcsub ($benchmark2, $benchmark1);

I am using php4.0.4pl1 as an apache module in apache 1.3.14 r2, running on win2k sp1.

I just hope it's a bug and not the result of staying up late trying to do some programming ;)

cu & keep up the good work. PHP is way cool.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-04 06:33 UTC]
unfortunately this is a bug for a long time now

Duplicate of #4968

 [2001-02-04 06:36 UTC]
unfortunately this is a bug for a long time now

Duplicate of #4968

 [2001-04-27 20:30 UTC]
Fixed in CVS. Wait for PHP 4.0.5.


PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Mar 31 10:04:43 2023 UTC