You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by nicolas de loof <ni...@apache.org> on 2008/02/01 15:50:28 UTC
[monitoring] timing precision : ms or ns ?
Hello,
For commons-monitoring my first intent was to use System.nanotime() to
compute code performances. A simple bench [1] demonstrates that
System.currentTimeMillis is FAR quicker to return current time (on my
windows box [2]) :
nanoseconds precision may be usefull for profilers, but is it for monitoring
purpose ?
[1] 10000000 time (System.nanoTime() ) vs (System.currentTimeMillis()) :
D:\projets\apache\trunks-sandbox\monitoring\target>java -server -cp
.\test-classes
org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
nanotime took : 4683052742ns
currentTimeMillis took : 26907938ns
[2]
D:\projets\apache\trunks-sandbox\monitoring\target>java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
BEA JRockit(R) (build R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
compiled mode)
Re: [monitoring] timing precision : ms or ns ?
Posted by nicolas de loof <ni...@apache.org>.
I got some more technical infos on performance comparison between
currentTimeMillis and nanoTime, that explain the poor performance of
nanoTime on windows (or the nice ones of currentTimeMillis)
I've setup a wiki page for this :
http://wiki.apache.org/commons/Monitoring/Precision
Nico.
2008/2/1, nicolas de loof <ni...@apache.org>:
>
> Interesting to see so different results for same JRE on Windows and SunOs.
> This demonstrates that such bench are never a final answer to java
> performance questions !
>
> Another such example is moksito test to compare synchronized to java5
> Atomics. On Sun JRE perfs are the oposite to Bea JRockit ones !
>
> Nico.
>
>
> 2008/2/1, sebb <se...@gmail.com>:
> >
> > Win XP Intel Core(2) T5500 1.66GHz
> >
> > System.nanoTime took : 2064849583ns
> > System.currentTimeMillis took : 62748478ns
> >
> > java version "1.5.0_13"
> > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
> > Java HotSpot(TM) Client VM (build 1.5.0_13-b05, mixed mode)
> >
> > On Hudson:
> > java version "1.5.0_13"
> > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
> > Java HotSpot(TM) Server VM (build 1.5.0_13-b05, mixed mode)
> > -bash-3.00$ uname -a
> > SunOS hudson.zones.apache.org 5.10 Generic_127112-05 i86pc i386 i86pc
> >
> > System.nanoTime took : 177830662ns
> > System.currentTimeMillis took : 199634480ns
> > -bash-3.00$ java NanoTest
> > System.nanoTime took : 166059518ns
> > System.currentTimeMillis took : 223041837ns
> > -bash-3.00$ java NanoTest
> > System.nanoTime took : 168053153ns
> > System.currentTimeMillis took : 204643068ns
> > -bash-3.00$ java NanoTest
> > System.nanoTime took : 169219738ns
> > System.currentTimeMillis took : 207292030ns
> >
> > Unfortunately the VMS system does not have Java 5 installed...
> >
> > On 01/02/2008, nicolas de loof <ni...@apache.org> wrote:
> > > My personnal result (Windows XP AMD Athlon XP 2800+):
> > >
> > > C:\>java -version
> > > java version "1.6.0_03"
> > > Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> > > Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
> > >
> > > System.nanoTime took : 1432396575ns
> > > System.currentTimeMillis took : 61866802ns
> > >
> > > -> currentTimeMillis is 20* quicker !
> > >
> > > Nico.
> > >
> > >
> > > 2008/2/1, nicolas de loof <ni...@apache.org>:
> > > >
> > > > and without stupide copy/paste colorde formatting :
> > > >
> > > >
> > > >
> > > > public class CurrentTimeMillisVsNanoTime
> > > > {
> > > >
> > > > static int loops = 1000000;
> > > > /**
> > > > * @param args
> > > > */
> > > > public static void main( String[] args )
> > > > {
> > > > long time = System.nanoTime();
> > > > long t;
> > > > for ( int i = 0; i < loops; i++ )
> > > > {
> > > > t = System.nanoTime();
> > > > }
> > > > System.out.println( "System.nanoTime took : " + (
> > > > System.nanoTime() - time ) + "ns" );
> > > >
> > > > time = System.nanoTime();
> > > > for ( int i = 0; i < loops; i++ )
> > > > {
> > > > t = System.currentTimeMillis();
> > > > }
> > > > System.out.println( "System.currentTimeMillis took : " + (
> > > > System.nanoTime() - time ) + "ns" );
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > 2008/2/1, nicolas de loof <ni...@apache.org>:
> > > > >
> > > > > I didn't commit from my office, but the bench looks like :
> > > > >
> > > > > *
> > > > >
> > > > > public
> > > > > **class* CurrentTimeMillisVsNanoTime
> > > > >
> > > > > {
> > > > >
> > > > > *static* *int* *loops* = 1000000;
> > > > >
> > > > > /**
> > > > >
> > > > > * *@param* args
> > > > >
> > > > > */
> > > > >
> > > > > *public* *static* *void* main( String[] args )
> > > > >
> > > > > {
> > > > >
> > > > > *long* time = System.*nanoTime*();
> > > > >
> > > > > *long* t;
> > > > >
> > > > > *for* ( *int* i = 0; i < *loops*; i++ )
> > > > >
> > > > > {
> > > > >
> > > > > t = System.*nanoTime*();
> > > > >
> > > > > }
> > > > >
> > > > > System.
> > > > > *out*.println( "System.nanoTime took : " + (System.*nanoTime*() -
> > time )
> > > > > + "ns" );
> > > > >
> > > > > time = System.*nanoTime*();
> > > > >
> > > > > *for* ( *int* i = 0; i < *loops*; i++ )
> > > > >
> > > > > {
> > > > >
> > > > > t = System.*currentTimeMillis*();
> > > > >
> > > > > }
> > > > >
> > > > > System.
> > > > > *out*.println( "System.currentTimeMillis took : " +
> > (System.*nanoTime*()
> > > > > - time ) + "ns" );
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > 2008/2/1, sebb <se...@gmail.com>:
> > > > > >
> > > > > > And I could probably run it on OpenVMS
> > > > > >
> > > > > > ;-)
> > > > > >
> > > > > > On 01/02/2008, Siegfried Goeschl <si...@it20one.at>
> > wrote:
> > > > > > > Hi Nicolas,
> > > > > > >
> > > > > > > if I either find the test code (or you commit it) I can tell
> > you on
> > > > > > Mac
> > > > > > > OS X .... :-)
> > > > > > >
> > > > > > > Siegfried Goeschl
> > > > > > >
> > > > > > > nicolas de loof wrote:
> > > > > > > > on java < 5 backport-util-concurrent is required to provide
> > > > > > > > System.nanotime()
> > > > > > > >
> > > > > > > > I've no idea of the result of such a bench on other JVM /
> > > > > > > > architectures. I'll try it on some of my corporate servers
> > > > > > (solaris /
> > > > > > > > linux ...)
> > > > > > > >
> > > > > > > > Having two timing modes would be a solution as you proposed.
> > > > > > > >
> > > > > > > > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > > > > > > > <ma...@it20one.at>>:
> > > > > > > >
> > > > > > > > Hi Nicolas,
> > > > > > > >
> > > > > > > > a few thoughts
> > > > > > > >
> > > > > > > > +) I use dynamic proxies together with JAMon to measure
> > the
> > > > > > execution
> > > > > > > > time of method invocations - ns would make a lot of
> > sense here
> > > > > > > > +) the execution times also depend on you JVM since you
> > are
> > > > > > using
> > > > > > > > JRockit
> > > > > > > > +) and finally it depends how often you start/stop a
> > monitor
> > > > > > > > +) retrotranslator will fail badly since System.nanotime()
> > was
> > > > > > > > introduced with Java 1.5
> > > > > > > >
> > > > > > > > Maybe the decision can be deferred until creating a
> > monitor -
> > > > > > the user
> > > > > > > > decides whether to use ms or ns?
> > > > > > > >
> > > > > > > > Cheers,
> > > > > > > >
> > > > > > > > Siegfried Goeschl
> > > > > > > >
> > > > > > > > nicolas de loof wrote:
> > > > > > > > > Hello,
> > > > > > > > >
> > > > > > > > > For commons-monitoring my first intent was to use
> > > > > > > > System.nanotime() to
> > > > > > > > > compute code performances. A simple bench [1]
> > demonstrates
> > > > > > that
> > > > > > > > > System.currentTimeMillis is FAR quicker to return
> > current
> > > > > > time
> > > > > > > > (on my
> > > > > > > > > windows box [2]) :
> > > > > > > > >
> > > > > > > > > nanoseconds precision may be usefull for profilers,
> > but is
> > > > > > it
> > > > > > > > for monitoring
> > > > > > > > > purpose ?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > [1] 10000000 time (System.nanoTime() ) vs
> > > > > > > > (System.currentTimeMillis()) :
> > > > > > > > >
> > > > > > > > >
> > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > > > > -server -cp
> > > > > > > > > .\test-classes
> > > > > > > > >
> > > > > > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > > > > > > > nanotime took : 4683052742ns
> > > > > > > > > currentTimeMillis took : 26907938ns
> > > > > > > > >
> > > > > > > > > [2]
> > > > > > > > >
> > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > > > > -version
> > > > > > > > > java version "1.6.0"
> > > > > > > > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > > > > > > > BEA JRockit(R) (build
> > > > > > > > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > > > > > > > compiled mode)
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > > > To unsubscribe, e-mail:
> > dev-unsubscribe@commons.apache.org
> > > > > > > > <ma...@commons.apache.org>
> > > > > > > > For additional commands, e-mail:
> > dev-help@commons.apache.org
> > > > > > > > <ma...@commons.apache.org>
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
Re: [monitoring] timing precision : ms or ns ?
Posted by nicolas de loof <ni...@apache.org>.
Interesting to see so different results for same JRE on Windows and SunOs.
This demonstrates that such bench are never a final answer to java
performance questions !
Another such example is moksito test to compare synchronized to java5
Atomics. On Sun JRE perfs are the oposite to Bea JRockit ones !
Nico.
2008/2/1, sebb <se...@gmail.com>:
>
> Win XP Intel Core(2) T5500 1.66GHz
>
> System.nanoTime took : 2064849583ns
> System.currentTimeMillis took : 62748478ns
>
> java version "1.5.0_13"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_13-b05, mixed mode)
>
> On Hudson:
> java version "1.5.0_13"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
> Java HotSpot(TM) Server VM (build 1.5.0_13-b05, mixed mode)
> -bash-3.00$ uname -a
> SunOS hudson.zones.apache.org 5.10 Generic_127112-05 i86pc i386 i86pc
>
> System.nanoTime took : 177830662ns
> System.currentTimeMillis took : 199634480ns
> -bash-3.00$ java NanoTest
> System.nanoTime took : 166059518ns
> System.currentTimeMillis took : 223041837ns
> -bash-3.00$ java NanoTest
> System.nanoTime took : 168053153ns
> System.currentTimeMillis took : 204643068ns
> -bash-3.00$ java NanoTest
> System.nanoTime took : 169219738ns
> System.currentTimeMillis took : 207292030ns
>
> Unfortunately the VMS system does not have Java 5 installed...
>
> On 01/02/2008, nicolas de loof <ni...@apache.org> wrote:
> > My personnal result (Windows XP AMD Athlon XP 2800+):
> >
> > C:\>java -version
> > java version "1.6.0_03"
> > Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> > Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
> >
> > System.nanoTime took : 1432396575ns
> > System.currentTimeMillis took : 61866802ns
> >
> > -> currentTimeMillis is 20* quicker !
> >
> > Nico.
> >
> >
> > 2008/2/1, nicolas de loof <ni...@apache.org>:
> > >
> > > and without stupide copy/paste colorde formatting :
> > >
> > >
> > >
> > > public class CurrentTimeMillisVsNanoTime
> > > {
> > >
> > > static int loops = 1000000;
> > > /**
> > > * @param args
> > > */
> > > public static void main( String[] args )
> > > {
> > > long time = System.nanoTime();
> > > long t;
> > > for ( int i = 0; i < loops; i++ )
> > > {
> > > t = System.nanoTime();
> > > }
> > > System.out.println( "System.nanoTime took : " + (
> > > System.nanoTime() - time ) + "ns" );
> > >
> > > time = System.nanoTime();
> > > for ( int i = 0; i < loops; i++ )
> > > {
> > > t = System.currentTimeMillis();
> > > }
> > > System.out.println( "System.currentTimeMillis took : " + (
> > > System.nanoTime() - time ) + "ns" );
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > 2008/2/1, nicolas de loof <ni...@apache.org>:
> > > >
> > > > I didn't commit from my office, but the bench looks like :
> > > >
> > > > *
> > > >
> > > > public
> > > > **class* CurrentTimeMillisVsNanoTime
> > > >
> > > > {
> > > >
> > > > *static* *int* *loops* = 1000000;
> > > >
> > > > /**
> > > >
> > > > * *@param* args
> > > >
> > > > */
> > > >
> > > > *public* *static* *void* main( String[] args )
> > > >
> > > > {
> > > >
> > > > *long* time = System.*nanoTime*();
> > > >
> > > > *long* t;
> > > >
> > > > *for* ( *int* i = 0; i < *loops*; i++ )
> > > >
> > > > {
> > > >
> > > > t = System.*nanoTime*();
> > > >
> > > > }
> > > >
> > > > System.
> > > > *out*.println( "System.nanoTime took : " + (System.*nanoTime*() -
> time )
> > > > + "ns" );
> > > >
> > > > time = System.*nanoTime*();
> > > >
> > > > *for* ( *int* i = 0; i < *loops*; i++ )
> > > >
> > > > {
> > > >
> > > > t = System.*currentTimeMillis*();
> > > >
> > > > }
> > > >
> > > > System.
> > > > *out*.println( "System.currentTimeMillis took : " +
> (System.*nanoTime*()
> > > > - time ) + "ns" );
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > 2008/2/1, sebb <se...@gmail.com>:
> > > > >
> > > > > And I could probably run it on OpenVMS
> > > > >
> > > > > ;-)
> > > > >
> > > > > On 01/02/2008, Siegfried Goeschl <si...@it20one.at>
> wrote:
> > > > > > Hi Nicolas,
> > > > > >
> > > > > > if I either find the test code (or you commit it) I can tell you
> on
> > > > > Mac
> > > > > > OS X .... :-)
> > > > > >
> > > > > > Siegfried Goeschl
> > > > > >
> > > > > > nicolas de loof wrote:
> > > > > > > on java < 5 backport-util-concurrent is required to provide
> > > > > > > System.nanotime()
> > > > > > >
> > > > > > > I've no idea of the result of such a bench on other JVM /
> > > > > > > architectures. I'll try it on some of my corporate servers
> > > > > (solaris /
> > > > > > > linux ...)
> > > > > > >
> > > > > > > Having two timing modes would be a solution as you proposed.
> > > > > > >
> > > > > > > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > > > > > > <ma...@it20one.at>>:
> > > > > > >
> > > > > > > Hi Nicolas,
> > > > > > >
> > > > > > > a few thoughts
> > > > > > >
> > > > > > > +) I use dynamic proxies together with JAMon to measure
> the
> > > > > execution
> > > > > > > time of method invocations - ns would make a lot of sense
> here
> > > > > > > +) the execution times also depend on you JVM since you
> are
> > > > > using
> > > > > > > JRockit
> > > > > > > +) and finally it depends how often you start/stop a
> monitor
> > > > > > > +) retrotranslator will fail badly since System.nanotime()
> was
> > > > > > > introduced with Java 1.5
> > > > > > >
> > > > > > > Maybe the decision can be deferred until creating a
> monitor -
> > > > > the user
> > > > > > > decides whether to use ms or ns?
> > > > > > >
> > > > > > > Cheers,
> > > > > > >
> > > > > > > Siegfried Goeschl
> > > > > > >
> > > > > > > nicolas de loof wrote:
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > For commons-monitoring my first intent was to use
> > > > > > > System.nanotime() to
> > > > > > > > compute code performances. A simple bench [1]
> demonstrates
> > > > > that
> > > > > > > > System.currentTimeMillis is FAR quicker to return
> current
> > > > > time
> > > > > > > (on my
> > > > > > > > windows box [2]) :
> > > > > > > >
> > > > > > > > nanoseconds precision may be usefull for profilers, but
> is
> > > > > it
> > > > > > > for monitoring
> > > > > > > > purpose ?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > [1] 10000000 time (System.nanoTime() ) vs
> > > > > > > (System.currentTimeMillis()) :
> > > > > > > >
> > > > > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > > > -server -cp
> > > > > > > > .\test-classes
> > > > > > > >
> > > > > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > > > > > > nanotime took : 4683052742ns
> > > > > > > > currentTimeMillis took : 26907938ns
> > > > > > > >
> > > > > > > > [2]
> > > > > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > > > -version
> > > > > > > > java version "1.6.0"
> > > > > > > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > > > > > > BEA JRockit(R) (build
> > > > > > > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > > > > > > compiled mode)
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > > > <ma...@commons.apache.org>
> > > > > > > For additional commands, e-mail:
> dev-help@commons.apache.org
> > > > > > > <ma...@commons.apache.org>
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > > >
> > > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > >
> > > > >
> > > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [monitoring] timing precision : ms or ns ?
Posted by sebb <se...@gmail.com>.
Win XP Intel Core(2) T5500 1.66GHz
System.nanoTime took : 2064849583ns
System.currentTimeMillis took : 62748478ns
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Client VM (build 1.5.0_13-b05, mixed mode)
On Hudson:
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Server VM (build 1.5.0_13-b05, mixed mode)
-bash-3.00$ uname -a
SunOS hudson.zones.apache.org 5.10 Generic_127112-05 i86pc i386 i86pc
System.nanoTime took : 177830662ns
System.currentTimeMillis took : 199634480ns
-bash-3.00$ java NanoTest
System.nanoTime took : 166059518ns
System.currentTimeMillis took : 223041837ns
-bash-3.00$ java NanoTest
System.nanoTime took : 168053153ns
System.currentTimeMillis took : 204643068ns
-bash-3.00$ java NanoTest
System.nanoTime took : 169219738ns
System.currentTimeMillis took : 207292030ns
Unfortunately the VMS system does not have Java 5 installed...
On 01/02/2008, nicolas de loof <ni...@apache.org> wrote:
> My personnal result (Windows XP AMD Athlon XP 2800+):
>
> C:\>java -version
> java version "1.6.0_03"
> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
>
> System.nanoTime took : 1432396575ns
> System.currentTimeMillis took : 61866802ns
>
> -> currentTimeMillis is 20* quicker !
>
> Nico.
>
>
> 2008/2/1, nicolas de loof <ni...@apache.org>:
> >
> > and without stupide copy/paste colorde formatting :
> >
> >
> >
> > public class CurrentTimeMillisVsNanoTime
> > {
> >
> > static int loops = 1000000;
> > /**
> > * @param args
> > */
> > public static void main( String[] args )
> > {
> > long time = System.nanoTime();
> > long t;
> > for ( int i = 0; i < loops; i++ )
> > {
> > t = System.nanoTime();
> > }
> > System.out.println( "System.nanoTime took : " + (
> > System.nanoTime() - time ) + "ns" );
> >
> > time = System.nanoTime();
> > for ( int i = 0; i < loops; i++ )
> > {
> > t = System.currentTimeMillis();
> > }
> > System.out.println( "System.currentTimeMillis took : " + (
> > System.nanoTime() - time ) + "ns" );
> > }
> >
> > }
> >
> >
> >
> > 2008/2/1, nicolas de loof <ni...@apache.org>:
> > >
> > > I didn't commit from my office, but the bench looks like :
> > >
> > > *
> > >
> > > public
> > > **class* CurrentTimeMillisVsNanoTime
> > >
> > > {
> > >
> > > *static* *int* *loops* = 1000000;
> > >
> > > /**
> > >
> > > * *@param* args
> > >
> > > */
> > >
> > > *public* *static* *void* main( String[] args )
> > >
> > > {
> > >
> > > *long* time = System.*nanoTime*();
> > >
> > > *long* t;
> > >
> > > *for* ( *int* i = 0; i < *loops*; i++ )
> > >
> > > {
> > >
> > > t = System.*nanoTime*();
> > >
> > > }
> > >
> > > System.
> > > *out*.println( "System.nanoTime took : " + (System.*nanoTime*() - time )
> > > + "ns" );
> > >
> > > time = System.*nanoTime*();
> > >
> > > *for* ( *int* i = 0; i < *loops*; i++ )
> > >
> > > {
> > >
> > > t = System.*currentTimeMillis*();
> > >
> > > }
> > >
> > > System.
> > > *out*.println( "System.currentTimeMillis took : " + (System.*nanoTime*()
> > > - time ) + "ns" );
> > >
> > > }
> > >
> > > }
> > >
> > >
> > >
> > > 2008/2/1, sebb <se...@gmail.com>:
> > > >
> > > > And I could probably run it on OpenVMS
> > > >
> > > > ;-)
> > > >
> > > > On 01/02/2008, Siegfried Goeschl <si...@it20one.at> wrote:
> > > > > Hi Nicolas,
> > > > >
> > > > > if I either find the test code (or you commit it) I can tell you on
> > > > Mac
> > > > > OS X .... :-)
> > > > >
> > > > > Siegfried Goeschl
> > > > >
> > > > > nicolas de loof wrote:
> > > > > > on java < 5 backport-util-concurrent is required to provide
> > > > > > System.nanotime()
> > > > > >
> > > > > > I've no idea of the result of such a bench on other JVM /
> > > > > > architectures. I'll try it on some of my corporate servers
> > > > (solaris /
> > > > > > linux ...)
> > > > > >
> > > > > > Having two timing modes would be a solution as you proposed.
> > > > > >
> > > > > > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > > > > > <ma...@it20one.at>>:
> > > > > >
> > > > > > Hi Nicolas,
> > > > > >
> > > > > > a few thoughts
> > > > > >
> > > > > > +) I use dynamic proxies together with JAMon to measure the
> > > > execution
> > > > > > time of method invocations - ns would make a lot of sense here
> > > > > > +) the execution times also depend on you JVM since you are
> > > > using
> > > > > > JRockit
> > > > > > +) and finally it depends how often you start/stop a monitor
> > > > > > +) retrotranslator will fail badly since System.nanotime() was
> > > > > > introduced with Java 1.5
> > > > > >
> > > > > > Maybe the decision can be deferred until creating a monitor -
> > > > the user
> > > > > > decides whether to use ms or ns?
> > > > > >
> > > > > > Cheers,
> > > > > >
> > > > > > Siegfried Goeschl
> > > > > >
> > > > > > nicolas de loof wrote:
> > > > > > > Hello,
> > > > > > >
> > > > > > > For commons-monitoring my first intent was to use
> > > > > > System.nanotime() to
> > > > > > > compute code performances. A simple bench [1] demonstrates
> > > > that
> > > > > > > System.currentTimeMillis is FAR quicker to return current
> > > > time
> > > > > > (on my
> > > > > > > windows box [2]) :
> > > > > > >
> > > > > > > nanoseconds precision may be usefull for profilers, but is
> > > > it
> > > > > > for monitoring
> > > > > > > purpose ?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > [1] 10000000 time (System.nanoTime() ) vs
> > > > > > (System.currentTimeMillis()) :
> > > > > > >
> > > > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > > -server -cp
> > > > > > > .\test-classes
> > > > > > >
> > > > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > > > > > nanotime took : 4683052742ns
> > > > > > > currentTimeMillis took : 26907938ns
> > > > > > >
> > > > > > > [2]
> > > > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > > -version
> > > > > > > java version "1.6.0"
> > > > > > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > > > > > BEA JRockit(R) (build
> > > > > > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > > > > > compiled mode)
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > > <ma...@commons.apache.org>
> > > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > > > <ma...@commons.apache.org>
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > >
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [monitoring] timing precision : ms or ns ?
Posted by nicolas de loof <ni...@apache.org>.
My personnal result (Windows XP AMD Athlon XP 2800+):
C:\>java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)
System.nanoTime took : 1432396575ns
System.currentTimeMillis took : 61866802ns
-> currentTimeMillis is 20* quicker !
Nico.
2008/2/1, nicolas de loof <ni...@apache.org>:
>
> and without stupide copy/paste colorde formatting :
>
>
>
> public class CurrentTimeMillisVsNanoTime
> {
>
> static int loops = 1000000;
> /**
> * @param args
> */
> public static void main( String[] args )
> {
> long time = System.nanoTime();
> long t;
> for ( int i = 0; i < loops; i++ )
> {
> t = System.nanoTime();
> }
> System.out.println( "System.nanoTime took : " + (
> System.nanoTime() - time ) + "ns" );
>
> time = System.nanoTime();
> for ( int i = 0; i < loops; i++ )
> {
> t = System.currentTimeMillis();
> }
> System.out.println( "System.currentTimeMillis took : " + (
> System.nanoTime() - time ) + "ns" );
> }
>
> }
>
>
>
> 2008/2/1, nicolas de loof <ni...@apache.org>:
> >
> > I didn't commit from my office, but the bench looks like :
> >
> > *
> >
> > public
> > **class* CurrentTimeMillisVsNanoTime
> >
> > {
> >
> > *static* *int* *loops* = 1000000;
> >
> > /**
> >
> > * *@param* args
> >
> > */
> >
> > *public* *static* *void* main( String[] args )
> >
> > {
> >
> > *long* time = System.*nanoTime*();
> >
> > *long* t;
> >
> > *for* ( *int* i = 0; i < *loops*; i++ )
> >
> > {
> >
> > t = System.*nanoTime*();
> >
> > }
> >
> > System.
> > *out*.println( "System.nanoTime took : " + (System.*nanoTime*() - time )
> > + "ns" );
> >
> > time = System.*nanoTime*();
> >
> > *for* ( *int* i = 0; i < *loops*; i++ )
> >
> > {
> >
> > t = System.*currentTimeMillis*();
> >
> > }
> >
> > System.
> > *out*.println( "System.currentTimeMillis took : " + (System.*nanoTime*()
> > - time ) + "ns" );
> >
> > }
> >
> > }
> >
> >
> >
> > 2008/2/1, sebb <se...@gmail.com>:
> > >
> > > And I could probably run it on OpenVMS
> > >
> > > ;-)
> > >
> > > On 01/02/2008, Siegfried Goeschl <si...@it20one.at> wrote:
> > > > Hi Nicolas,
> > > >
> > > > if I either find the test code (or you commit it) I can tell you on
> > > Mac
> > > > OS X .... :-)
> > > >
> > > > Siegfried Goeschl
> > > >
> > > > nicolas de loof wrote:
> > > > > on java < 5 backport-util-concurrent is required to provide
> > > > > System.nanotime()
> > > > >
> > > > > I've no idea of the result of such a bench on other JVM /
> > > > > architectures. I'll try it on some of my corporate servers
> > > (solaris /
> > > > > linux ...)
> > > > >
> > > > > Having two timing modes would be a solution as you proposed.
> > > > >
> > > > > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > > > > <ma...@it20one.at>>:
> > > > >
> > > > > Hi Nicolas,
> > > > >
> > > > > a few thoughts
> > > > >
> > > > > +) I use dynamic proxies together with JAMon to measure the
> > > execution
> > > > > time of method invocations - ns would make a lot of sense here
> > > > > +) the execution times also depend on you JVM since you are
> > > using
> > > > > JRockit
> > > > > +) and finally it depends how often you start/stop a monitor
> > > > > +) retrotranslator will fail badly since System.nanotime() was
> > > > > introduced with Java 1.5
> > > > >
> > > > > Maybe the decision can be deferred until creating a monitor -
> > > the user
> > > > > decides whether to use ms or ns?
> > > > >
> > > > > Cheers,
> > > > >
> > > > > Siegfried Goeschl
> > > > >
> > > > > nicolas de loof wrote:
> > > > > > Hello,
> > > > > >
> > > > > > For commons-monitoring my first intent was to use
> > > > > System.nanotime() to
> > > > > > compute code performances. A simple bench [1] demonstrates
> > > that
> > > > > > System.currentTimeMillis is FAR quicker to return current
> > > time
> > > > > (on my
> > > > > > windows box [2]) :
> > > > > >
> > > > > > nanoseconds precision may be usefull for profilers, but is
> > > it
> > > > > for monitoring
> > > > > > purpose ?
> > > > > >
> > > > > >
> > > > > >
> > > > > > [1] 10000000 time (System.nanoTime() ) vs
> > > > > (System.currentTimeMillis()) :
> > > > > >
> > > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > -server -cp
> > > > > > .\test-classes
> > > > > >
> > > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > > > > nanotime took : 4683052742ns
> > > > > > currentTimeMillis took : 26907938ns
> > > > > >
> > > > > > [2]
> > > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > > -version
> > > > > > java version "1.6.0"
> > > > > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > > > > BEA JRockit(R) (build
> > > > > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > > > > compiled mode)
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > > <ma...@commons.apache.org>
> > > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > > <ma...@commons.apache.org>
> > > > >
> > > > >
> > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
>
Re: [monitoring] timing precision : ms or ns ?
Posted by nicolas de loof <ni...@apache.org>.
and without stupide copy/paste colorde formatting :
public class CurrentTimeMillisVsNanoTime
{
static int loops = 1000000;
/**
* @param args
*/
public static void main( String[] args )
{
long time = System.nanoTime();
long t;
for ( int i = 0; i < loops; i++ )
{
t = System.nanoTime();
}
System.out.println( "System.nanoTime took : " + (
System.nanoTime() - time ) + "ns" );
time = System.nanoTime();
for ( int i = 0; i < loops; i++ )
{
t = System.currentTimeMillis();
}
System.out.println( "System.currentTimeMillis took : " + (
System.nanoTime() - time ) + "ns" );
}
}
2008/2/1, nicolas de loof <ni...@apache.org>:
>
> I didn't commit from my office, but the bench looks like :
>
> *
>
> public
> **class* CurrentTimeMillisVsNanoTime
>
> {
>
> *static* *int* *loops* = 1000000;
>
> /**
>
> * *@param* args
>
> */
>
> *public* *static* *void* main( String[] args )
>
> {
>
> *long* time = System.*nanoTime*();
>
> *long* t;
>
> *for* ( *int* i = 0; i < *loops*; i++ )
>
> {
>
> t = System.*nanoTime*();
>
> }
>
> System.
> *out*.println( "System.nanoTime took : " + (System.*nanoTime*() - time ) +
> "ns" );
>
> time = System.*nanoTime*();
>
> *for* ( *int* i = 0; i < *loops*; i++ )
>
> {
>
> t = System.*currentTimeMillis*();
>
> }
>
> System.
> *out*.println( "System.currentTimeMillis took : " + (System.*nanoTime*() -
> time ) + "ns" );
>
> }
>
> }
>
>
>
> 2008/2/1, sebb <se...@gmail.com>:
> >
> > And I could probably run it on OpenVMS
> >
> > ;-)
> >
> > On 01/02/2008, Siegfried Goeschl <si...@it20one.at> wrote:
> > > Hi Nicolas,
> > >
> > > if I either find the test code (or you commit it) I can tell you on
> > Mac
> > > OS X .... :-)
> > >
> > > Siegfried Goeschl
> > >
> > > nicolas de loof wrote:
> > > > on java < 5 backport-util-concurrent is required to provide
> > > > System.nanotime()
> > > >
> > > > I've no idea of the result of such a bench on other JVM /
> > > > architectures. I'll try it on some of my corporate servers (solaris
> > /
> > > > linux ...)
> > > >
> > > > Having two timing modes would be a solution as you proposed.
> > > >
> > > > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > > > <ma...@it20one.at>>:
> > > >
> > > > Hi Nicolas,
> > > >
> > > > a few thoughts
> > > >
> > > > +) I use dynamic proxies together with JAMon to measure the
> > execution
> > > > time of method invocations - ns would make a lot of sense here
> > > > +) the execution times also depend on you JVM since you are
> > using
> > > > JRockit
> > > > +) and finally it depends how often you start/stop a monitor
> > > > +) retrotranslator will fail badly since System.nanotime() was
> > > > introduced with Java 1.5
> > > >
> > > > Maybe the decision can be deferred until creating a monitor -
> > the user
> > > > decides whether to use ms or ns?
> > > >
> > > > Cheers,
> > > >
> > > > Siegfried Goeschl
> > > >
> > > > nicolas de loof wrote:
> > > > > Hello,
> > > > >
> > > > > For commons-monitoring my first intent was to use
> > > > System.nanotime() to
> > > > > compute code performances. A simple bench [1] demonstrates
> > that
> > > > > System.currentTimeMillis is FAR quicker to return current time
> > > > (on my
> > > > > windows box [2]) :
> > > > >
> > > > > nanoseconds precision may be usefull for profilers, but is it
> > > > for monitoring
> > > > > purpose ?
> > > > >
> > > > >
> > > > >
> > > > > [1] 10000000 time (System.nanoTime() ) vs
> > > > (System.currentTimeMillis()) :
> > > > >
> > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > -server -cp
> > > > > .\test-classes
> > > > >
> > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > > > nanotime took : 4683052742ns
> > > > > currentTimeMillis took : 26907938ns
> > > > >
> > > > > [2]
> > > > > D:\projets\apache\trunks-sandbox\monitoring\target>java
> > -version
> > > > > java version "1.6.0"
> > > > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > > > BEA JRockit(R) (build
> > > > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > > > compiled mode)
> > > > >
> > > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > <ma...@commons.apache.org>
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > > <ma...@commons.apache.org>
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
Re: [monitoring] timing precision : ms or ns ?
Posted by nicolas de loof <ni...@apache.org>.
I didn't commit from my office, but the bench looks like :
*
public* *class* CurrentTimeMillisVsNanoTime
{
*static* *int* *loops* = 1000000;
/**
* *@param* args
*/
*public* *static* *void* main( String[] args )
{
*long* time = System.*nanoTime*();
*long* t;
*for* ( *int* i = 0; i < *loops*; i++ )
{
t = System.*nanoTime*();
}
System.*out*.println( "System.nanoTime took : " + (System.*nanoTime*() -
time ) + "ns" );
time = System.*nanoTime*();
*for* ( *int* i = 0; i < *loops*; i++ )
{
t = System.*currentTimeMillis*();
}
System.*out*.println( "System.currentTimeMillis took : " + (System.*nanoTime
*() - time ) + "ns" );
}
}
2008/2/1, sebb <se...@gmail.com>:
>
> And I could probably run it on OpenVMS
>
> ;-)
>
> On 01/02/2008, Siegfried Goeschl <si...@it20one.at> wrote:
> > Hi Nicolas,
> >
> > if I either find the test code (or you commit it) I can tell you on Mac
> > OS X .... :-)
> >
> > Siegfried Goeschl
> >
> > nicolas de loof wrote:
> > > on java < 5 backport-util-concurrent is required to provide
> > > System.nanotime()
> > >
> > > I've no idea of the result of such a bench on other JVM /
> > > architectures. I'll try it on some of my corporate servers (solaris /
> > > linux ...)
> > >
> > > Having two timing modes would be a solution as you proposed.
> > >
> > > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > > <ma...@it20one.at>>:
> > >
> > > Hi Nicolas,
> > >
> > > a few thoughts
> > >
> > > +) I use dynamic proxies together with JAMon to measure the
> execution
> > > time of method invocations - ns would make a lot of sense here
> > > +) the execution times also depend on you JVM since you are using
> > > JRockit
> > > +) and finally it depends how often you start/stop a monitor
> > > +) retrotranslator will fail badly since System.nanotime() was
> > > introduced with Java 1.5
> > >
> > > Maybe the decision can be deferred until creating a monitor - the
> user
> > > decides whether to use ms or ns?
> > >
> > > Cheers,
> > >
> > > Siegfried Goeschl
> > >
> > > nicolas de loof wrote:
> > > > Hello,
> > > >
> > > > For commons-monitoring my first intent was to use
> > > System.nanotime() to
> > > > compute code performances. A simple bench [1] demonstrates that
> > > > System.currentTimeMillis is FAR quicker to return current time
> > > (on my
> > > > windows box [2]) :
> > > >
> > > > nanoseconds precision may be usefull for profilers, but is it
> > > for monitoring
> > > > purpose ?
> > > >
> > > >
> > > >
> > > > [1] 10000000 time (System.nanoTime() ) vs
> > > (System.currentTimeMillis()) :
> > > >
> > > > D:\projets\apache\trunks-sandbox\monitoring\target>java -server
> -cp
> > > > .\test-classes
> > > > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > > nanotime took : 4683052742ns
> > > > currentTimeMillis took : 26907938ns
> > > >
> > > > [2]
> > > > D:\projets\apache\trunks-sandbox\monitoring\target>java -version
> > > > java version "1.6.0"
> > > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > > BEA JRockit(R) (build
> > > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > > compiled mode)
> > > >
> > > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > <ma...@commons.apache.org>
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > > <ma...@commons.apache.org>
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [monitoring] timing precision : ms or ns ?
Posted by sebb <se...@gmail.com>.
And I could probably run it on OpenVMS
;-)
On 01/02/2008, Siegfried Goeschl <si...@it20one.at> wrote:
> Hi Nicolas,
>
> if I either find the test code (or you commit it) I can tell you on Mac
> OS X .... :-)
>
> Siegfried Goeschl
>
> nicolas de loof wrote:
> > on java < 5 backport-util-concurrent is required to provide
> > System.nanotime()
> >
> > I've no idea of the result of such a bench on other JVM /
> > architectures. I'll try it on some of my corporate servers (solaris /
> > linux ...)
> >
> > Having two timing modes would be a solution as you proposed.
> >
> > 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> > <ma...@it20one.at>>:
> >
> > Hi Nicolas,
> >
> > a few thoughts
> >
> > +) I use dynamic proxies together with JAMon to measure the execution
> > time of method invocations - ns would make a lot of sense here
> > +) the execution times also depend on you JVM since you are using
> > JRockit
> > +) and finally it depends how often you start/stop a monitor
> > +) retrotranslator will fail badly since System.nanotime() was
> > introduced with Java 1.5
> >
> > Maybe the decision can be deferred until creating a monitor - the user
> > decides whether to use ms or ns?
> >
> > Cheers,
> >
> > Siegfried Goeschl
> >
> > nicolas de loof wrote:
> > > Hello,
> > >
> > > For commons-monitoring my first intent was to use
> > System.nanotime() to
> > > compute code performances. A simple bench [1] demonstrates that
> > > System.currentTimeMillis is FAR quicker to return current time
> > (on my
> > > windows box [2]) :
> > >
> > > nanoseconds precision may be usefull for profilers, but is it
> > for monitoring
> > > purpose ?
> > >
> > >
> > >
> > > [1] 10000000 time (System.nanoTime() ) vs
> > (System.currentTimeMillis()) :
> > >
> > > D:\projets\apache\trunks-sandbox\monitoring\target>java -server -cp
> > > .\test-classes
> > > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > > nanotime took : 4683052742ns
> > > currentTimeMillis took : 26907938ns
> > >
> > > [2]
> > > D:\projets\apache\trunks-sandbox\monitoring\target>java -version
> > > java version "1.6.0"
> > > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > > BEA JRockit(R) (build
> > R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > > compiled mode)
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > <ma...@commons.apache.org>
> > For additional commands, e-mail: dev-help@commons.apache.org
> > <ma...@commons.apache.org>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [monitoring] timing precision : ms or ns ?
Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Nicolas,
if I either find the test code (or you commit it) I can tell you on Mac
OS X .... :-)
Siegfried Goeschl
nicolas de loof wrote:
> on java < 5 backport-util-concurrent is required to provide
> System.nanotime()
>
> I've no idea of the result of such a bench on other JVM /
> architectures. I'll try it on some of my corporate servers (solaris /
> linux ...)
>
> Having two timing modes would be a solution as you proposed.
>
> 2008/2/1, Siegfried Goeschl <siegfried.goeschl@it20one.at
> <ma...@it20one.at>>:
>
> Hi Nicolas,
>
> a few thoughts
>
> +) I use dynamic proxies together with JAMon to measure the execution
> time of method invocations - ns would make a lot of sense here
> +) the execution times also depend on you JVM since you are using
> JRockit
> +) and finally it depends how often you start/stop a monitor
> +) retrotranslator will fail badly since System.nanotime() was
> introduced with Java 1.5
>
> Maybe the decision can be deferred until creating a monitor - the user
> decides whether to use ms or ns?
>
> Cheers,
>
> Siegfried Goeschl
>
> nicolas de loof wrote:
> > Hello,
> >
> > For commons-monitoring my first intent was to use
> System.nanotime() to
> > compute code performances. A simple bench [1] demonstrates that
> > System.currentTimeMillis is FAR quicker to return current time
> (on my
> > windows box [2]) :
> >
> > nanoseconds precision may be usefull for profilers, but is it
> for monitoring
> > purpose ?
> >
> >
> >
> > [1] 10000000 time (System.nanoTime() ) vs
> (System.currentTimeMillis()) :
> >
> > D:\projets\apache\trunks-sandbox\monitoring\target>java -server -cp
> > .\test-classes
> > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > nanotime took : 4683052742ns
> > currentTimeMillis took : 26907938ns
> >
> > [2]
> > D:\projets\apache\trunks-sandbox\monitoring\target>java -version
> > java version "1.6.0"
> > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > BEA JRockit(R) (build
> R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> > compiled mode)
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> <ma...@commons.apache.org>
> For additional commands, e-mail: dev-help@commons.apache.org
> <ma...@commons.apache.org>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [monitoring] timing precision : ms or ns ?
Posted by nicolas de loof <ni...@apache.org>.
on java < 5 backport-util-concurrent is required to provide System.nanotime()
I've no idea of the result of such a bench on other JVM / architectures.
I'll try it on some of my corporate servers (solaris / linux ...)
Having two timing modes would be a solution as you proposed.
2008/2/1, Siegfried Goeschl <si...@it20one.at>:
>
> Hi Nicolas,
>
> a few thoughts
>
> +) I use dynamic proxies together with JAMon to measure the execution
> time of method invocations - ns would make a lot of sense here
> +) the execution times also depend on you JVM since you are using JRockit
> +) and finally it depends how often you start/stop a monitor
> +) retrotranslator will fail badly since System.nanotime() was
> introduced with Java 1.5
>
> Maybe the decision can be deferred until creating a monitor - the user
> decides whether to use ms or ns?
>
> Cheers,
>
> Siegfried Goeschl
>
> nicolas de loof wrote:
> > Hello,
> >
> > For commons-monitoring my first intent was to use System.nanotime() to
> > compute code performances. A simple bench [1] demonstrates that
> > System.currentTimeMillis is FAR quicker to return current time (on my
> > windows box [2]) :
> >
> > nanoseconds precision may be usefull for profilers, but is it for
> monitoring
> > purpose ?
> >
> >
> >
> > [1] 10000000 time (System.nanoTime() ) vs (System.currentTimeMillis()) :
> >
> > D:\projets\apache\trunks-sandbox\monitoring\target>java -server -cp
> > .\test-classes
> > org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> > nanotime took : 4683052742ns
> > currentTimeMillis took : 26907938ns
> >
> > [2]
> > D:\projets\apache\trunks-sandbox\monitoring\target>java -version
> > java version "1.6.0"
> > Java(TM) SE Runtime Environment (build 1.6.0-b105)
> > BEA JRockit(R) (build R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32
> ,
> > compiled mode)
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [monitoring] timing precision : ms or ns ?
Posted by Siegfried Goeschl <si...@it20one.at>.
Hi Nicolas,
a few thoughts
+) I use dynamic proxies together with JAMon to measure the execution
time of method invocations - ns would make a lot of sense here
+) the execution times also depend on you JVM since you are using JRockit
+) and finally it depends how often you start/stop a monitor
+) retrotranslator will fail badly since System.nanotime() was
introduced with Java 1.5
Maybe the decision can be deferred until creating a monitor - the user
decides whether to use ms or ns?
Cheers,
Siegfried Goeschl
nicolas de loof wrote:
> Hello,
>
> For commons-monitoring my first intent was to use System.nanotime() to
> compute code performances. A simple bench [1] demonstrates that
> System.currentTimeMillis is FAR quicker to return current time (on my
> windows box [2]) :
>
> nanoseconds precision may be usefull for profilers, but is it for monitoring
> purpose ?
>
>
>
> [1] 10000000 time (System.nanoTime() ) vs (System.currentTimeMillis()) :
>
> D:\projets\apache\trunks-sandbox\monitoring\target>java -server -cp
> .\test-classes
> org.apache.commons.monitoring.bench.CurrentTimeMillisVsNanoTime
> nanotime took : 4683052742ns
> currentTimeMillis took : 26907938ns
>
> [2]
> D:\projets\apache\trunks-sandbox\monitoring\target>java -version
> java version "1.6.0"
> Java(TM) SE Runtime Environment (build 1.6.0-b105)
> BEA JRockit(R) (build R27.2.0-131-78843-1.6.0-20070320-1457-windows-ia32,
> compiled mode)
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org