Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can we know what is the execution time taken for completing a Operation

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

How can i know what is the execution time taken for completing an operation .
My query is that for example I am fetching data from DataBase and it can be done using Statements and PreperaedStatements also know , so i want to know what is the time taken when using Statements and what time in case of PreparedStatements .

Please let me know is there any tool for this .

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check the system time at the start and the end of the method and look at the difference.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you .

But i want to see all these on tools .

so is any tool like this .
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, you want a Java profiling tool! Let me google that for you: java profiler. Hmm, I did not see VisualVM mentioned in the results (I probably missed it).
 
Kees Jan Koster
JavaMonitor Support
Rancher
Posts: 251
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And there are the logging database drivers (mysql driver has this built-in, or you can use p6spy).
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always use the getTime() method of the Date class. This can be used as a quick and dirty millisecond timer. it returns a value of type long. So taking two measurements and substracting the first from the second gives you elapsed time in milliseconds.

It's not a replacement for a proper profiling tool I guess. Just a quick and easy time check.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JAMon sql proxy drive sits in front of the actual db driver and times all queries and other aspects of jdbc.

http://jamonapi.sourceforge.net/#WhatsNew22
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic