OJB
Downloads
Documentation
Development
Translated (Web)
|
The OJB Performance Test Suite |
Introduction |
"
There is no such thing as a free lunch."
(North American proverb)
Object/relational mapping tools hide the details of relational
databases from the application developer. The developer can
concentrate on implementing business logic and is liberated from
caring about RDBMS related coding with JDBC and SQL.
O/R mapping tools allow to separate business logic from RDBMS
access by forming an additional software layer between business logic
and RDBMS. Introducing new software layers always eats up additional
computing resources.
In short: the price for using O/R tools is performance.
Software architects have to take in account this tradeoff between
programming comfort and performance to decide if it is appropiate to
use an O/R tool for a specific software system.
This document describes the OJB Performance Test Suite
which was created to lighten the decision between native JDBC,
OJB and other O/R mapper.
|
Interpreting test results |
Interpreting the result of these benchmarks carefully will help to
decide whether using OJB is viable for specific application scenarios
or if native JDBC programming should be used for performance reasons.
Take care of compareable configuration properties when run
performance tests with different O/R tools.
If the decision made to use an O/R mapping tool the comparison with
other tools helps to find the best one for the thought scenario.
But performance shouldn't be the only reason to take a specific
O/R tool. There are many other points to consider:
- Usability of the supported API's
- Flexibility of the framework
- Scalability of the framework
- Community support
- The different licences of Open Source projects
- etcetera ...
|
How OJB compares to other O/R mapping tools? |
Many user ask this question and there is more than one answer. But OJB was
shipped with a simple performance framework which allows a rudimentarily
comparision of OJB with other (java-based) O/R mapping tools.
Call bin\build.bat perf-test-jar or bin/build.sh perf-test-jar
to build the jar file contain all necessary classes to set up a test with an
arbitrary O/R mapper. After build the db-ojb-XXX-performance.jar can
be found in [db-ojb]/dist directory.
Steps to set up the test:
- Implement a class derived from
org.apache.ojb.performance.PerfTest
- Implement a class derived from
org.apache.ojb.performance.PerfHandle
- [If persistent objects used within your mapping tool must be derived from a special base
class or must be implement a special interface write your own persistent object class
by implementing
org.apache.ojb.performance.PerfArticle interface and override
method newPerfArticle() in your PerfHandle implementation class.
Otherwise the test use a default implementation of this interface.]
That's it!
You can find a example implementation called
org.apache.ojb.broker.OJBPerfTest in the test-sources directory
under [db-ojb]/src/test/org/apache/ojb (when using source-distribution).
This implementation class is used to compare the PB-API, ODMG-API and native JDBC and
to test performance of the API implementations. See more section
multi-threaded performance. OJBPerfTest
is made up of inner classes. At each case two inner classes represent a test for
one api (as described above).
Run the test
You have two possibilities to run the test:
a) Integration in the OJB build script
Add the full qualified class name of your PerfTest implementation class
to the perf-test target of the OJB build.xml
file, add all necessary jar files to [db-ojb]/lib . The working
directory of the test is [db-ojb]/target/test/ojb .
b) Run PerfMain
It's possible to run the test using org.apache.ojb.performance.PerfMain .
 |  |  |
 |
java -classpath CLASSPATH org.apache.ojb.performance.PerfMain
[comma separated list of PerfTest implementation classes, no blanks!]
[number of test loops]
[number of threads]
[number of insert/fetch/delete loops per thread]
[boolean - run in stress mode if set true,
run in performance mode if set false, default false]
For example:
java -classpath CLASSPATH my.A_PerfTest,my.B_PerfTest 3 10 2000 false
|  |
 |  |  |
Take care of compareable configuration properties when run
performance tests with different O/R tools (caching, locking,
sequence key generation, connection pooling, ...).
Please:
Don't start flame wars by posting performance results to
mailing lists made with this simple test. This test was created for
OJB QA and to give a clue how good or bad OJB performs, NOT to start
discussion like XY is 12% faster then XZ!!.
|
|
|