0

Is there an easy way to measure executiontime of a whole block ? This is a closed code big Java WAR application so I think it is hard to introduce startTime/endTime blocks by some AOP.

// startTime

PreparedStatement prep = ...
ResultSet rs = prep.executeQuery();
// iterate over whole rs

// endTime
// executionTime = endTime - startTime

Assuming a Connection is returned to a db pool after each statement one could use the timing of "Connection in use" time provided by some Java app servers. But I am looking for the easiest solution.

j23
  • 160
  • 9
  • You could wrap "real" connection in some own code - this would make it possible to start timer on PreparedStatement.executeQuery() and end timer in ResultSet.close() I guess. And delegate objects are easy to create with eclipse... – Jan Jun 23 '16 at 11:52
  • I am thinking of BTrace + VisualVM integration to easily log hog methods. – j23 Jun 28 '16 at 08:52

1 Answers1

0

Just to close the question: I added a few lines to log4jdbc code to measure the whole time (since start query to close result set) and log it when above a threshold.

j23
  • 160
  • 9