db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4462) Use System.nanoTime on JDK 1.5 and higher to get finer precision internal measurements
Date Sat, 05 Dec 2009 13:13:20 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4462?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12786401#action_12786401
] 

Kristian Waagan commented on DERBY-4462:
----------------------------------------

Hi Bryan,

I know measuring elapsed time is not always as simple as one would like, and I have some comments.

Regarding System.currentTimeMillis, I think the resolution ("update rate") depends on the
OS (and to some degree the hardware).
For instance, a rule of thumb for clock resolution used to be up to ~15 ms for Windows, 10
ms for Linux 2.4 and 1 ms for Linux 2.6. I checked the resolution on a Core 2 Quad system
running Windows Vista, and it gave me 1 ms. So it seems the situation is improving at least
on some platforms. 

Switching to System.nanoTime is a good move. One should realize that it doesn't provide any
guarantees that the resolution is better than for System.currentTimeMillis, but in practice
I believe the former provides a higher resolution than the latter on modern systems.
Also, System.nanoTime is defined in relative terms, whereas System.currentTimeMillis is defined
in absolute terms. Values from the two cannot be used together (i.e. System.currentTimeMillis()
 - (System.nanoTime() / 1000000) is not valid), and values from System.nanoTime cannot be
used across JVM boundaries.

> Use System.nanoTime on JDK 1.5 and higher to get finer precision internal measurements
> --------------------------------------------------------------------------------------
>
>                 Key: DERBY-4462
>                 URL: https://issues.apache.org/jira/browse/DERBY-4462
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Bryan Pendleton
>            Priority: Minor
>
> Derby uses System.currentTimeMillis() to compute the internal elapsed time of certain
operations.
> For example, the parseTime, bindTime, optimizeTime, generateTime, and compileTime measurements
> that are computed by GenericStatement.prepMinion use this technique.
> System.currentTimeMillis is not terribly accurate, since it is only updated 60 times
a second; this
> means that it doesn't give very good information about operations that take less than
16 milliseconds,
> and the compilation time of a SQL statement is often shorter than that.
> As Knut Anders observes, we could use System.nanoTime, which is available in JDK 1.5
and above,
> to make more precise measurements.
> See DERBY-4297 for some related observations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message