Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Am I right in a way to measure CPU time consumed by a block of code?

Reply
Thread Tools

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

 
 
www
Guest
Posts: n/a
 
      04-05-2007
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.

Am I right? Thank you.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Am I right in a way to measure CPU time consumed by a block of code? www Java 1 04-05-2007 10:01 PM
How to measure the CPU time a program takes? www Java 14 04-05-2007 09:28 PM
finding how much time that is consumed? raybakk@yahoo.no C Programming 5 08-20-2006 07:46 PM
Nachi-A worm consumed all of router's memory? duder Cisco 1 12-12-2003 08:40 PM
Web Service throws 401 Error when consumed Sanjay ASP .Net 4 11-20-2003 04:03 AM



Advertisments