Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Am I right in a way to measure CPU time consumed by a block of code?

Thread view: 
www - 05 Apr 2007 21:46 GMT
Hi,

I want to measure the CPU time, not the "apparent" user time, consumed
by a block of code in my Java program. This Java program was translated
from Fortran program and now we want to do some bench mark to compare
with its original Fortran program, but we don't want to count those I/O
operations. We just want to focus on the block of code doing heavy duty
scientific computations. The command

time java MyJavaClassName

will give the user time and system time spent for the whole program from
beginning to the end.

I came a "silly" idea for measuring the system time used by the block of
code we are interested in by using "time" command:

for(int i=1; i<=20; i++)
{
    //code for doing computation
}

Then

time java MyJavaClassName

The extra system time is due to 19 runs of computation. The extra system
time used divided it by 19 gives me the system time for a single
computation.

The result is that the system time used by Java code is even LESS than
the Fortran code. Is the result trustable? Or some kind of buffering
makes the number too small?

(Fortunately, there is a easy way in Fortran to measure the user time,
system time used by a block of code. like
http://infohost.nmt.edu/tcc/help/lang/fortran/elapsed.html)

Am I right? Thank you.
Lew - 05 Apr 2007 23:01 GMT
> Hi,
>
[quoted text clipped - 25 lines]
> time used divided it by 19 gives me the system time for a single
> computation.

> Am I right? Thank you.

As pointed out in the other independent thread you started on this topic, "How
to measure the CPU time a program takes?", no.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.