• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Profilling HQL?.. (Good Understanding)

 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers..

is there any good way to count the estimate time which needed to run a HQL?..
in my application now..
i count the time needed to execute HQL with JUnit..
my code is like the following code :


is this a good idea?..
is there any another way?..
Thanks in advance..
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Leonardo,

I think this kind of "profiling" test won't give you reliable results. If you run this test against a real database backend there will be many caching effects (database, JPA, file system, OS) and something like this which could lead to very varying results from test run to test run and of course database server to database server.

I'm not an expert in performance testing databases but I guess it would be more appropriate to do some kind of stress test or performance tests which runs this test multiple times and maybe concurrently with multiple connections. But then of course this definitely isn't a good unit test anymore. You should probably move it to a separate test suite for such tests. Unfortunately the absolute estimated time for these queries still depends on the performance of your test client machine and your database server and DBMS but it's still better than running this test only one with your other unit tests.

Perhaps I should mention that you probably shouldn't worry too much about this fine tuning except this part is really a performance bottleneck for your application

Marco
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic