This topic applies to Java version only
The code for this section is located in the com.db4o.bench.delaying package.
To run delaying, the System.nanoTime()
is needed. This method was introduced with Java 5.
If you only have older versions installed, get the latest here: http://java.sun.com/javase/downloads/
You
also need a java5 db4o JAR file, otherwise you'll see a
NotImplementedException when the benchmark tries to access nanoTime()
.
Think
of the following scenario: You develop software with db4o for a target
system, that has much slower I/O than your developer system (e.g. an
embedded device).
Wouldn't it sometimes be nice getting a feel
for the expected speed your application will work with on the target
system without having to deploy to it?
In particular, if you want to profile your system with a profiler like JProbe, simulating the expected slow I/O on a device will help you identifying the bottlenecks in your application.
This
is where the results of IoBenchmark and a DelayingIoAdapter enter the
arena. If you run IoBenchmark on both the embedded device and your
developer machine you get two results files. Copy the file from the
slower device to the db4otools folder on the faster machine and set
both filenames in IoBenchmark.properties:
results.file.1=db4o-IoBenchmark-results-30000_faster.logIt's not necessary that results.file.1 holds the faster log, any order will work.
results.file.2=db4o-IoBenchmark-results-30000_slower.log
=============================================================Let's have a look at what exactly is going on when setting up delaying.
Running db4o IoBenchmark
=============================================================
Delaying:
> machine1 (db4o-IoBenchmark-results-30000_faster.log) is faster!
> Required delays:
> [delays in nanoseconds] read: 8195 | write: 10669 | seek: 10098 | sync: 215121
> Adjusting delay timer to match required delays...
> Adjusted delays:
> [delays in nanoseconds] read: 4934 | write: 7387 | seek: 6849 | sync: 202203
Running target application ...
Preparing DB file ...
Running benchmark ...
[...]
>> Smallest achievable delay: 400To find out which delay actually was too small, and hence which results won't be accurate, take a look at the adjusted delays:
>> Required delay setting: 260
>> Using delay(0) to wait as short as possible.
>> Results will not be accurate.
> Adjusted delays:Here the read delay was too small and therefore the results for read are expected to be slower than targeted.
> [delays in nanoseconds] read: 0 | write: 7387 | seek: 6849 | sync: 202203
IoAdapter rafFactory = new RandomAccessFileAdapter();
IoAdapter delFactory = new DelayingIoAdapter(rafFactory, _delays);
IoAdapter io = delFactory.open(dbFileName, false, 0, false);