Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to record CPU time of a java program

 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm doing a publication, implementing an AVL tree, Binary Search Tree and Top Down Splay Tree using Java. I need to test the performance of this data structures in terms of CPU time. Several insertions, deletions and searches will be performed on them. I need to get the CPU time for this operations... any help?? I've heard that using Unix could probably be a good idea..
thanks
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a side-by-side comparision you can just use the system time before and after each process that you want to compare. Something like
long start = System.currentTimeMillis();
As for actually determining the number of cpu cycles, I'm not sure.
Sean
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is actually pretty simple if you are using a UNIX based platform. Just use
time -p java <....all the arguments.. >
This should give you the actual time elapsed along with CPU times.
 
Naveen Kuppili
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually since you are doing comparison studies.. you would be better off executing
time java ...
insetad of
time -p java ...
this would give you accuracy upto milli seconds.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic