A few things

  * You were sharing the connection and the statement in the JDBC
tests.  But in the iBATIS tests you were outside of a
session/transaction scope.  So to make it fair, you either need to
open/close the connection and create/close the statement each time.
  * You were using Statement vs. iBATIS' PreparedStatement
  * You were too creative with the timings... you should not attempt
to sum up a bunch of individual times when benchmarking -- the OS
isn't that accurate.  So you should just time the entire execution of
all of the iterations.
  * You should code your tests carefully, it will help clear up a lot
of things that are hard to see when code is hacked out.  Use
interfaces and a common timer class to make things clear.
  * Not sure why you're using such an odd query for the benchmark.
  * Not sure why you're using an empty database for the benchmark.

There were a couple of other things unrelated to the benchmarking.
You don't have to use individual CDATA sections for <  and > in the
SQL.  Just wrap the whole statement unless you're using Dynamic SQL,
in which case you can block out just the conditional, or use &lt; &gt;

That's all I can remember. :-)

Here's an updated test that scopes the iBATIS calls in a
session/transaction and both the JDBC and iBATIS versions execute
100,000 iterations around 16 seconds on my crappy HP laptop.  :-)

http://clintonbegin.com/downloads/jdbc_ibatis_benchmark_0.3.zip

I think you'll find that even if there are a few places where iBATIS
is slower, it's not slow enough to worry about.   We're talking
milliseconds usually.

Cheers,
Clinton

On Sun, Mar 22, 2009 at 8:13 PM, Jeff P <killingd...@hotmail.com> wrote:
>
> I was in the process of stresstesting my app and found out that my count
> queries weren't optimal. I've produced the following JDBC test and iBatis
> test and the test says iBatis is 6 times slower.
>
> I know iBatis should be just as fast as JDBC, so I refuse to accept that
> outcome. However I can't figure out what i'm overlooking. I've re-read the
> manual pdf two times to find out performance steps which I might have missed
> (had good hopes for caching) but alas, didn't make any change.
>
> I've made an, as small as possible, sample which reproduces my
> mini-benchmark. The attached file includes SQL creation code, JDBC benchmark
> and iBatis benchmark which should all run without any problem. Only
> prerequisite is to have MySQL installed and the xml files configured
> correctly.
>
> I hope someone can push me in the right direction.
> Thank you in advance.
>
> http://www.nabble.com/file/p22653299/jdbc_ibatis_benchmark_0.2.rar
> jdbc_ibatis_benchmark_0.2.rar
>
>
>
> --
> View this message in context: 
> http://www.nabble.com/iBatis-6x-slower%2C-what-am-I-overlooking--tp22653299p22653299.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Reply via email to