![]() |
|
Version: 0.27 - Last update: 2004-05-30 | Home Page - SourceForge Project Page - Contact |
Jodd Overview News Download License References Development Using Jodd Javadoc JUnit report Community Contribute Report a bug More reading Milestone 0.30 ![]() ![]() |
SqlUtilProfilerSometimes there is a need to profile SQL queries in the application, i.e. to measure the execution time ofexecuteQuery() and
executeUpdate() methods. Jodd makes this possible without
any external (and expensive) tool: just instance
SqlUtilProfiler instead SqlUtil .SqlUtilProfiler overloads (i.e. wraps) SqlUtil
and measures the execution time of all queries. After query execution is
complete and time has been measured, these data will be sent to user-made
callback SqlProfilerHandler object. Simple as that.Here is the example. Instead of the default use of the SqlUtil :
the SqlUtilProfiler would be used for profiling:
Of course, to be able to collect profiled data, a callback object should be created somewhere during application initialization and assigned to SqlUtilProfiler :
To deactivate profiling there is no need to alter the code, it is just enough to set handler to null instead:
Profiled code obviously runs a bit slower, which mainly depends on the implementation of the SqlProfilerHandler . When profiling is
off, the code will run as there is no profiling at all, practically
without any additional time delays.Note:, Jodd currently doesn't provide any implementation of SqlProfilerHandler . |