Update db4o operation requires disk access and therefore is very dependent on the disk speed. To emulate a different drive speed we will use a RAMDISK utility, which creates an alternative storage media in the memory.
UpdatePerformanceBenchmark.cs: RunHardDriveTest
private void RunHardDriveTest()
{
System.Console.WriteLine("Update test: hard drive");
int objectsToUpdate = 90;
InitForHardDriveTest();
Clean();
Open(ConfigureDriveTest());
Store();
System.Console.WriteLine("Updating " + objectsToUpdate +
" objects on a hard drive:");
UpdateItems(objectsToUpdate);
Close();
}
UpdatePerformanceBenchmark.cs: InitForHardDriveTest
private void InitForHardDriveTest()
{
_count = 10000;
_depth = 3;
_filePath = "performance.db4o";
_isClientServer = false;
}
UpdatePerformanceBenchmark.cs: RunRamDiskTest
private void RunRamDiskTest()
{
System.Console.WriteLine("Update test: RAM disk");
int objectsToUpdate = 90;
InitForRamDriveTest();
Clean();
Open(ConfigureDriveTest());
Store();
System.Console.WriteLine("Updating " + objectsToUpdate
+ " objects on a RAM drive:");
UpdateItems(objectsToUpdate);
Close();
}
UpdatePerformanceBenchmark.cs: InitForRamDriveTest
private void InitForRamDriveTest()
{
_count = 30000;
_depth = 1;
_filePath = "r:\\performance.db4o";
_isClientServer = false;
}
UpdatePerformanceBenchmark.cs: ConfigureDriveTest
private IConfiguration ConfigureDriveTest()
{
IConfiguration config = Db4oFactory.NewConfiguration();
config.FlushFileBuffers(true);
return config;
}
The results:
Update test: hard drive
Store 30000 objects: 2884ms
Updating 90 objects on a hard drive:
Updated 90 items: 250ms
Update test: RAM disk
Store 30000 objects: 1910ms
Updating 90 objects on a RAM drive:
Updated 90 items: 105ms
The test shows that the faster media (RAMDISK) shows better performance on update.
Download example code: