You are here: Tuning > Main Operations Performance > Insert Performance > Local And Remote Modes

Local And Remote Modes

Of course local and client/server modes cannot give the same performance and it is difficult to say what will be the impact of inserting the objects over the network, as the network conditions can vary.

You can use the following test to compare the performance on your network:

InsertPerformanceBenchmark.cs: RunClientServerTest
private void RunClientServerTest()
         {
            ConfigureClientServer();

            Init();
            Clean();
            System.Console.WriteLine("Storing " + _count + " objects of depth " 
+ _depth + " locally:");
            Open();
            Store();
            Close();

            InitForClientServer();
            Clean();
            System.Console.WriteLine("Storing " + _count + " objects of depth " 
+ _depth + " remotely:");
            Open();
            Store();
            Close();
        }
InsertPerformanceBenchmark.cs: ConfigureClientServer
private void ConfigureClientServer()
         {
            IConfiguration config = Db4oFactory.Configure();
            config.LockDatabaseFile(false);
            config.WeakReferences(false);
            config.FlushFileBuffers(false);
            config.ClientServer().SingleThreadedClient(true);
        }
InsertPerformanceBenchmark.cs: Init
private void Init()
         {
            _count = 10000;
            _depth = 3;
            _isClientServer = false;
        }
InsertPerformanceBenchmark.cs: InitForClientServer
private void InitForClientServer()
         {
            _count = 10000;
            _depth = 3;
            _isClientServer = true;
        }
InsertPerformanceBenchmark.cs: Store
private void Store()
         {
            StartTimer();
            for (int i = 0; i < _count; i++)
             {
                Item item = new Item("load", null);
                for (int j = 1; j < _depth; j++)
                 {
                    item = new Item("load", item);
                }
                objectContainer.Store(item);
            }
            objectContainer.Commit();
            StopTimer("Store " + TotalObjects() + " objects");
        }

With a good and reliable network you can use the same methods to improve the insert performance as in a local mode. However, if your network connection is not always perfect you will need to use commits more often to ensure that the objects do not get lost. See the next chapter for recommendations on commit performance.

Download example code:

c#