Thank you Charlie.  You of course are right about time.time().  It couldn't be improved using nanoTime.  Time clock should be relatively easy though and should improve things by quite a bit.  I will put my example scripts together with a naive first pass at a solution and open a problem.

I imagine Python uses getTimeOfDay() on unix like systems for time.time().  time.time() could could still be improved using JNI and getTimeOfDay() on Unix like systems and then Jython's resolution would basically match Pythons (since Pythons Windows XP resolution for time.time() really isn't any better than Jythons).  I understand that it isn;'t quite as simple of an enhancement though to use JNI.  Does/would Jython consider using JNI and c for time.time()?

 - Bob



-----Original Message-----
From: Charlie Groves <charlie.groves@gmail.com>
To: boblusebob@aim.com
Cc: jython-dev@lists.sourceforge.net
Sent: Fri, 23 Nov 2007 1:43 pm
Subject: Re: [Jython-dev] Jython Clock Resolution

On Nov 17, 2007 3:50 PM,  <boblusebob@aim.com> wrote:
> I was looking into the clock resolution for Jython and ran into something
> that doesn't seen right to me. I ran simple tests on Windows XP and Linux
> and came up with the following results:
>
> Windows XP
> Python
> time.clock() - 2 microseconds
> time.time() - 15 milliseconds
>
> Jython
> time.clock() - 15 milliseconds
> time.time() - 15 milliseconds
>
> Linux
> Python
> time.clock() - 10 milliseconds
> time.time() - 5 microseconds
>
> Jython
> time.clock() - 1 millisecond
> time.time() - 1 millisecond
>
> Shouldn't time.clock() on Jython for Windows and time.time() on Linux have
> much better resolution? I believe that if Jython used Java nanoTime it
> could reach these levels. Am I way off base?

I don't think there's anything we can do about the resolution of
time.time. I don't see how it could be done with System.nanoTime
since that just yields the number of nanoseconds since the first time
it was called and has no bearing on the time since the epoch. We
could probably use nanoTime for time.clock though and get better
numbers.

> I have simple scripts to demo this if anyone is interested, and will open a
> problem against the current code if that is where the problem is, but I
> don't know the plan for Jython to implement clock timing.

If you want to file a bug for time.clock with your scripts, I'll see
about switching it to use nanoTime.

Charlie

Check Out the new free AIM(R) Mail -- Unlimited storage and industry-leading spam and email virus protection.