Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001119 [Quercus] minor always 05-17-06 12:02 05-19-06 13:19
Reporter koreth View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 3.0.20 Product Version 3.0.20
  Product Build
Summary 0001119: microtime() is only millisecond-accurate, is formatted incorrectly (w/patch)
Description We use microtime() to do some internal profiling of database queries and communication with backend servers. It appears that Quercus' microtime() is broken in two ways: it is not microsecond-accurate (since it's based on System.currentTimeMillis()) and its string output is in the wrong format (should be ".012345 6789" instead of "12345 67890".)

Here's a patch. I did the initial divide by 1000 because I found it hard to visually count all the zeros in the subsequent division and modulo operations.


--- resin-3.0.s060516/modules/quercus/src/com/caucho/quercus/lib/DateModule.java2006-05-10 19:50:42.000000000 -0700
+++ old/060516/resin-3.0.s060516/modules/quercus/src/com/caucho/quercus/lib/DateModule.java 2006-05-16 18:12:45.000000000 -0700
@@ -603,13 +603,13 @@
    */
   public static Value microtime(@Optional boolean getAsFloat)
   {
- long now = Alarm.getCurrentTime();
+ long now = Alarm.getExactTimeNanoseconds() / 1000;
 
     if (getAsFloat) {
- return new DoubleValue((double) now / 1000.0);
+ return new DoubleValue((double) now / 1000000.0);
     }
     else {
- return new StringValueImpl((now % 1000 * 1000) + " " + (now / 1000));
+ return new StringValueImpl((now % 1000000) / 1000000.0 + " " + (now / 1000000));
     }
   }
Steps To Reproduce
Additional Information
Attached Files

- Relationships

- Notes
(0001159)
ferg
05-19-06 13:19

php/1903
 

- Issue History
Date Modified Username Field Change
05-17-06 12:02 koreth New Issue
05-19-06 13:19 ferg Note Added: 0001159
05-19-06 13:19 ferg Assigned To  => ferg
05-19-06 13:19 ferg Status new => closed
05-19-06 13:19 ferg Resolution open => fixed
05-19-06 13:19 ferg Fixed in Version  => 3.0.20


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker