Quote:
I would suggest you stop putting down everybody who shows unfavorable results.
Well listen, I am trying not to put you down, but so far you have taken up more than an hour of my time with a silly benchmark that
(1) showed no awareness of the impact of HotSpot (namely that Java code runs faster the more times you execute it)
(2) showed no awareness of the difference between Statement and PreparedStatement
(3) compared JDBC code that read some data and then
did nothing with it, against some Hibernate code, that not only returned the results into a list, but also added it to the session-level cache (I showed you how to avoid that overhead using "select new Foo(...) ...")
(4) probably has various other problems (you have not shown any information about session handling, connection pooling, etc)
I mean, it would be difficult to design a more flawed benchmark if I tried.
What you are forgetting here is that
I actually know what the true overhead is, since I have spent many hours doing benchmarking work. Don't you get frustrated when someone comes and tries to argue with you about something when
you know they are wrong. What about if you had to have this same argument approximately once a month every month??
Lets add up the cumulative improvements already:
(1) use of select new: 100% difference
(2) fair test of PreparedStatement: 50%ish difference on top of that
(3) actually do something with the data in the JDBC test 20% difference
(4) do stuff in a long enough loop to take advantage of HotSpot opimizations: x% improvement (20 may or may not be enough)
If I'm not mistaken, we are now down in about the 10%-20% range. I have no idea what other "buried treasure" waits to be discovered.
Oh, and
(5) take advantage of query caching: y% improvement
Now Hibernate is actually faster than JDBC.
To be brutally honest, would rather just ignore your flawed benchmark and get on with more serious work. Unfortunately, I have to respond to your benchmark since otherwise otherwise other people will read this thread and think it is correct.