Ejemplo n.º 1
0
        public async Task DBFiles_BTree_Test_27_UpdateObject()
        {
            Simple Obj      = CreateSimple(this.MaxStringLength);
            Guid   ObjectId = await this.file.SaveNewObject(Obj);

            AssertEx.NotSame(Guid.Empty, ObjectId);

            Simple Obj2 = await this.file.LoadObject <Simple>(ObjectId);

            DBFilesObjectSerializationTests.AssertEqual(Obj, Obj2);

            Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeBefore.xml"));

            Simple Obj3 = CreateSimple(this.MaxStringLength);

            Obj3.ObjectId = ObjectId;
            await this.file.UpdateObject(Obj3);

            Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeAfter.xml"));

            Obj2 = await this.file.LoadObject <Simple>(ObjectId);

            DBFilesObjectSerializationTests.AssertEqual(Obj3, Obj2);

            await AssertConsistent(this.file, this.provider, null, null, true);

            Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTree.xml"));
        }
        private async Task Test_Add(int MaxLen)
        {
            byte[] ByteArray = this.GetBytes(MaxLen, 0);
            Simple Obj       = DBFilesBTreeTests.CreateSimple(MaxLen);

            await this.file.AddAsync("Key1", "Value1");

            await this.file.AddAsync("Key2", "Value2");

            await this.file.AddAsync("Key3", "Value3");

            await this.file.AddAsync("Key4", null);

            await this.file.AddAsync("Key5", Obj);

            await this.file.AddAsync("Key6", ByteArray);

            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1");
            AssertEx.Same(this.file["Key2"], "Value2");
            AssertEx.Same(this.file["Key3"], "Value3");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj);
            AssertEx.Same(this.file["Key6"], ByteArray);
        }
Ejemplo n.º 3
0
        public async Task DBFiles_Provider_01_ByReference()
        {
            ByReference Obj = new ByReference()
            {
                Default = DBFilesBTreeTests.CreateDefault(100),
                Simple  = DBFilesBTreeTests.CreateSimple(100)
            };

            await this.provider.Insert(Obj);

            ObjectBTreeFile File = await this.provider.GetFile("Default");

            await DBFilesBTreeTests.AssertConsistent(File, this.provider, 3, Obj, true);

            Console.Out.WriteLine(await DBFilesBTreeTests.ExportXML(File, "Data\\BTree.xml"));

            Assert.AreNotEqual(Guid.Empty, Obj.ObjectId);
            Assert.AreNotEqual(Guid.Empty, Obj.Default.ObjectId);
            Assert.AreNotEqual(Guid.Empty, Obj.Simple.ObjectId);

            ByReference Obj2 = await this.provider.LoadObject <ByReference>(Obj.ObjectId);

            DBFilesObjectSerializationTests.AssertEqual(Obj2.Default, Obj.Default);
            DBFilesObjectSerializationTests.AssertEqual(Obj2.Simple, Obj.Simple);
        }
        public async Task DBFiles_StringDictionary_02_Add()
        {
            byte[] ByteArray = new byte[] { 1, 2, 3, 4, 5 };
            Simple Obj       = DBFilesBTreeTests.CreateSimple(100);

            await this.file.AddAsync("Key1", "Value1");

            await this.file.AddAsync("Key2", "Value2");

            await this.file.AddAsync("Key3", "Value3");

            await this.file.AddAsync("Key4", null);

            await this.file.AddAsync("Key5", Obj);

            await this.file.AddAsync("Key6", ByteArray);

            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1");
            AssertEx.Same(this.file["Key2"], "Value2");
            AssertEx.Same(this.file["Key3"], "Value3");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj);
            AssertEx.Same(this.file["Key6"], ByteArray);
        }
Ejemplo n.º 5
0
        public async Task DBFiles_BTree_Test_01_X_Repeat_DBFiles_BTree_Test_01()
        {
            object LastObjectAdded = null;

            try
            {
                List <Simple> Objects = new List <Simple>();
                List <Guid>   ObjectIds = new List <Guid>();
                int           i, c = 0;

                Simple Obj = CreateSimple(this.MaxStringLength);
                Guid   ObjectId = await this.file.SaveNewObject(LastObjectAdded = Obj);

                AssertEx.NotSame(Guid.Empty, ObjectId);

                Objects.Add(Obj);
                ObjectIds.Add(ObjectId);
                c++;

                Simple Obj2 = await this.file.LoadObject <Simple>(ObjectIds[0]);

                DBFilesObjectSerializationTests.AssertEqual(Obj, Obj2);

                while (true)
                {
                    this.TestCleanup();
                    await this.TestInitialize();

                    Obj      = CreateSimple(this.MaxStringLength);
                    ObjectId = await this.file.SaveNewObject(LastObjectAdded = Obj);

                    AssertEx.NotSame(Guid.Empty, ObjectId);

                    //FileStatistics Stat = await AssertConsistent(this.file, this.provider, null, Obj, false);

                    Objects.Add(Obj);
                    ObjectIds.Add(ObjectId);
                    c++;

                    for (i = 0; i < c; i++)
                    {
                        Obj2 = await this.file.LoadObject <Simple>(ObjectIds[i]);
                    }

                    DBFilesObjectSerializationTests.AssertEqual(Obj, Obj2);

                    //Console.Out.Write(Stat.NrObjects.ToString() + " ");
                    Console.Out.Write(c.ToString() + " ");
                }
            }
            catch (Exception ex)
            {
                SaveLastObject(this.provider, LastObjectAdded);

                ExceptionDispatchInfo.Capture(ex).Throw();
            }
        }
Ejemplo n.º 6
0
        public async Task DBFiles_BTree_Test_04_LoadUntyped()
        {
            Simple Obj      = CreateSimple(this.MaxStringLength);
            Guid   ObjectId = await this.file.SaveNewObject(Obj);

            AssertEx.NotSame(Guid.Empty, ObjectId);

            GenericObject Obj2 = (GenericObject)await this.file.LoadObject(ObjectId);

            DBFilesObjectSerializationTests.AssertEqual(Obj, Obj2);

            await AssertConsistent(this.file, this.provider, 1, Obj, true);
        }
        private async Task Test_CopyTo(int MaxLen)
        {
            byte[] ByteArray = this.GetBytes(MaxLen, 0);
            Simple Obj       = DBFilesBTreeTests.CreateSimple(MaxLen);

            this.file["Key1"] = "Value1";
            this.file["Key2"] = "Value2";
            this.file["Key3"] = "Value3";
            this.file["Key4"] = null;
            this.file["Key5"] = Obj;
            this.file["Key6"] = ByteArray;
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1");
            AssertEx.Same(this.file["Key2"], "Value2");
            AssertEx.Same(this.file["Key3"], "Value3");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj);
            AssertEx.Same(this.file["Key6"], ByteArray);

            int c = this.file.Count;

            AssertEx.Same(6, c);

            KeyValuePair <string, object>[] A = new KeyValuePair <string, object> [c];
            this.file.CopyTo(A, 0);

            AssertEx.Same(A[0].Key, "Key1");
            AssertEx.Same(A[1].Key, "Key2");
            AssertEx.Same(A[2].Key, "Key3");
            AssertEx.Same(A[3].Key, "Key4");
            AssertEx.Same(A[4].Key, "Key5");
            AssertEx.Same(A[5].Key, "Key6");

            AssertEx.Same(A[0].Value, "Value1");
            AssertEx.Same(A[1].Value, "Value2");
            AssertEx.Same(A[2].Value, "Value3");
            Assert.IsNull(A[3].Value);
            DBFilesObjectSerializationTests.AssertEqual(A[4].Value as Simple, Obj);
            AssertEx.Same(A[5].Value, ByteArray);
        }
        private async Task Test_Reset(int MaxLen)
        {
            byte[] ByteArray1 = this.GetBytes(MaxLen, 0);
            byte[] ByteArray2 = this.GetBytes(MaxLen, MaxLen);
            Simple Obj1       = DBFilesBTreeTests.CreateSimple(MaxLen);
            Simple Obj2       = DBFilesBTreeTests.CreateSimple(MaxLen);

            this.file["Key1"] = "Value1_1";
            this.file["Key2"] = "Value2_1";
            this.file["Key3"] = "Value3_1";
            this.file["Key4"] = null;
            this.file["Key5"] = Obj1;
            this.file["Key6"] = ByteArray1;
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1_1");
            AssertEx.Same(this.file["Key2"], "Value2_1");
            AssertEx.Same(this.file["Key3"], "Value3_1");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj1);
            AssertEx.Same(this.file["Key6"], ByteArray1);

            this.file["Key1"] = "Value1_2";
            this.file["Key2"] = "Value2_2";
            this.file["Key3"] = "Value3_2";
            this.file["Key4"] = null;
            this.file["Key5"] = Obj2;
            this.file["Key6"] = ByteArray2;
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1_2");
            AssertEx.Same(this.file["Key2"], "Value2_2");
            AssertEx.Same(this.file["Key3"], "Value3_2");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj2);
            AssertEx.Same(this.file["Key6"], ByteArray2);
        }
        public async Task DBFiles_StringDictionary_03_Reset()
        {
            byte[] ByteArray1 = new byte[] { 1, 2, 3, 4, 5 };
            byte[] ByteArray2 = new byte[] { 6, 7, 8, 9, 0 };
            Simple Obj1       = DBFilesBTreeTests.CreateSimple(100);
            Simple Obj2       = DBFilesBTreeTests.CreateSimple(100);

            this.file["Key1"] = "Value1_1";
            this.file["Key2"] = "Value2_1";
            this.file["Key3"] = "Value3_1";
            this.file["Key4"] = null;
            this.file["Key5"] = Obj1;
            this.file["Key6"] = ByteArray1;
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1_1");
            AssertEx.Same(this.file["Key2"], "Value2_1");
            AssertEx.Same(this.file["Key3"], "Value3_1");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj1);
            AssertEx.Same(this.file["Key6"], ByteArray1);

            this.file["Key1"] = "Value1_2";
            this.file["Key2"] = "Value2_2";
            this.file["Key3"] = "Value3_2";
            this.file["Key4"] = null;
            this.file["Key5"] = Obj2;
            this.file["Key6"] = ByteArray2;
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key1"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key2"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key3"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key4"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key5"));
            Assert.IsTrue(await this.file.ContainsKeyAsync("Key6"));
            AssertEx.Same(this.file["Key1"], "Value1_2");
            AssertEx.Same(this.file["Key2"], "Value2_2");
            AssertEx.Same(this.file["Key3"], "Value3_2");
            Assert.IsNull(this.file["Key4"]);
            DBFilesObjectSerializationTests.AssertEqual(this.file["Key5"] as Simple, Obj2);
            AssertEx.Same(this.file["Key6"], ByteArray2);
        }
Ejemplo n.º 10
0
        private async Task DBFiles_BTree_Test_UpdateObjects(int c)
        {
            Simple[] Objects = new Simple[c];
            Simple   Obj;
            int      i;

            for (i = 0; i < c; i++)
            {
                Objects[i] = Obj = CreateSimple(this.MaxStringLength);
                await this.file.SaveNewObject(Obj);
            }

            //await AssertConsistent(this.file, this.provider, null, null, true);
            //Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeBeforeUpdates.xml"));

            for (i = 0; i < c; i++)
            {
                Obj          = CreateSimple(this.MaxStringLength);
                Obj.ObjectId = Objects[i].ObjectId;

                await this.file.UpdateObject(Obj);

                Objects[i] = Obj;

                Obj = await this.file.LoadObject <Simple>(Obj.ObjectId);

                DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj);
            }

            await AssertConsistent(this.file, this.provider, null, null, true);

            //Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeAfterUpdates.xml"));

            for (i = 0; i < c; i++)
            {
                Obj = await this.file.LoadObject <Simple>(Objects[i].ObjectId);

                DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj);
            }
        }
Ejemplo n.º 11
0
        public async Task DBFiles_BTree_Test_22_SelectIthObject()
        {
            int c = ObjectsToEnumerate;
            SortedDictionary <Guid, Simple> Objects = await this.CreateObjects(c);

            Simple[] Ordered = new Simple[c];
            Objects.Values.CopyTo(Ordered, 0);
            Guid?  Prev = null;
            Simple Obj;
            Random gen = new Random();
            int    i, j;

            for (i = 0; i < c; i++)
            {
                j    = 0;
                Prev = null;

                if (i < 10 || (gen.Next(0, 2) == 0 && i <= c - 10))
                {
                    using (ObjectBTreeFileEnumerator <Simple> e = await this.file.GetTypedEnumeratorAsync <Simple>(true))
                    {
                        Assert.IsTrue(await e.GoToObject((uint)i));

                        do
                        {
                            Obj = e.Current;
                            if (Prev.HasValue)
                            {
                                AssertEx.Less(Prev.Value, Obj.ObjectId);
                            }

                            Prev = Obj.ObjectId;
                            DBFilesObjectSerializationTests.AssertEqual(Ordered[i + j], Obj);

                            AssertEx.Same(i + j, e.CurrentRank);
                            AssertEx.Same(Obj.ObjectId, e.CurrentObjectId);
                        }while (e.MoveNext() && j++ < 10);
                    }
                }
                else
                {
                    using (ObjectBTreeFileEnumerator <Simple> e = await this.file.GetTypedEnumeratorAsync <Simple>(true))
                    {
                        Assert.IsTrue(await e.GoToObject((uint)i));

                        do
                        {
                            Obj = e.Current;
                            if (Prev.HasValue)
                            {
                                AssertEx.Greater(Prev.Value, Obj.ObjectId);
                            }

                            Prev = Obj.ObjectId;
                            DBFilesObjectSerializationTests.AssertEqual(Ordered[i - j], Obj);

                            AssertEx.Same(i - j, e.CurrentRank);
                            AssertEx.Same(Obj.ObjectId, e.CurrentObjectId);
                        }while (e.MovePrevious() && j++ < 10);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private async Task TestMultiple(int c, bool AssertIndividually, int?LogStatisticsEvery)
        {
            DateTime Start                     = DateTime.Now;
            List <FileStatistics> Stat         = null;
            List <double>         Milliseconds = null;
            int i;

            Simple[] Objects = new Simple[c];
            Simple   Obj2;

            for (i = 0; i < c; i++)
            {
                Objects[i] = CreateSimple(this.MaxStringLength);
                await this.file.SaveNewObject(Objects[i]);

                if (AssertIndividually)
                {
                    Console.Out.WriteLine();
                    Console.Out.WriteLine((i + 1).ToString() + " objects:");
                    Console.Out.WriteLine(new string('-', 80));

                    await AssertConsistent(this.file, this.provider, i + 1, Objects[i], true);
                }

                if (LogStatisticsEvery.HasValue && (i + 1) % LogStatisticsEvery.Value == 0)
                {
                    if (Stat == null)
                    {
                        Milliseconds = new List <double>();
                        Stat         = new List <FileStatistics>();
                    }

                    Milliseconds.Add((DateTime.Now - Start).TotalMilliseconds / LogStatisticsEvery.Value);
                    Stat.Add(await this.file.ComputeStatistics());

                    Start = DateTime.Now;
                }
            }

            for (i = 0; i < c; i++)
            {
                Obj2 = await this.file.LoadObject <Simple>(Objects[i].ObjectId);

                DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj2);
            }

            if (!AssertIndividually)
            {
                await AssertConsistent(this.file, this.provider, c, null, true);
            }

            if (Stat != null)
            {
                Variables v = new Variables()
                {
                    { "Stat", Stat.ToArray() },
                    { "ms", Milliseconds.ToArray() },
                    { "StepSize", LogStatisticsEvery.Value }
                };

                Expression Exp = new Expression("[ms,Stat.BlockSize,Stat.NrBlocks,Stat.NrBytesUsed,Stat.NrBytesUnused,Stat.NrBytesTotal," +
                                                "Stat.Usage,Stat.NrObjects,Stat.MinObjectSize,Stat.MaxObjectSize,Stat.AverageObjectSize,Stat.MinDepth,Stat.MaxDepth," +
                                                "Stat.NrBlockLoads,Stat.NrCacheLoads,Stat.NrBlockSaves,Stat.MinObjectsPerBlock,Stat.MaxObjectsPerBlock," +
                                                "Stat.AverageObjectsPerBlock,Stat.MinBytesUsedPerBlock,Stat.MaxBytesUsedPerBlock,Stat.AverageBytesUsedPerBlock]T");

                Console.Out.WriteLine("ms, BlockSize, NrBlocks, NrBytesUsed, NrBytesUnused, NrBytesTotal, " +
                                      "Usage, NrObjects, MinObjectSize, MaxObjectSize, AverageObjectSize, MinDepth, MaxDepth, " +
                                      "NrBlockLoads, NrCacheLoads, NrBlockSaves,Min(Obj/Block),Max(Obj/Block),Avg(Obj/Block)," +
                                      "Min(UsedBytes/Block),Max(UsedBytes/Block),Avg(UsedBytes/Block)");
                Console.Out.WriteLine(new string('-', 80));
                Console.Out.WriteLine(Exp.Evaluate(v).ToString());
            }
        }
Ejemplo n.º 13
0
        private async Task DBFiles_BTree_Test_DeleteObjects(int c, bool CheckForEachObject)
        {
            Random Gen = new Random();

            Simple[] Objects = new Simple[c];
            Simple   Obj;
            int      i;

            for (i = 0; i < c; i++)
            {
                Objects[i] = Obj = CreateSimple(this.MaxStringLength);
                await this.file.SaveNewObject(Obj);
            }

            while (c > 0)
            {
                i = Gen.Next(0, c);

                Obj = Objects[i];
                c--;
                if (i < c)
                {
                    Array.Copy(Objects, i + 1, Objects, i, c - i);
                }

                if (CheckForEachObject)
                {
                    try
                    {
                        this.provider.CloseFile(this.file.CollectionName);
                        this.file = null;

                        File.Copy(FileName, FileName + ".bak", true);
                        File.Copy(BlobFileName, BlobFileName + ".bak", true);
                        File.Copy(NamesFileName, NamesFileName + ".bak", true);

                        this.file = await this.provider.GetFile(CollectionName);

                        if (File.Exists(ObjIdFileName))
                        {
                            File.Delete(ObjIdFileName);
                        }

                        File.WriteAllBytes(ObjIdFileName, Obj.ObjectId.ToByteArray());

                        if (File.Exists(BlockSizeFileName))
                        {
                            File.Delete(BlockSizeFileName);
                        }

                        File.WriteAllText(BlockSizeFileName, this.BlockSize.ToString());

                        Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeBefore.xml"));
                        Console.Out.WriteLine(Obj.ObjectId);
                        await this.file.DeleteObject(Obj);

                        //Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeAfter.xml"));
                        await AssertConsistent(this.file, this.provider, null, null, true);

                        for (i = 0; i < c; i++)
                        {
                            Obj = await this.file.LoadObject <Simple>(Objects[i].ObjectId);

                            DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (this.file != null)
                        {
                            Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeError.xml"));
                        }

                        ExceptionDispatchInfo.Capture(ex).Throw();
                    }
                }
                else
                {
                    await this.file.DeleteObject(Obj);
                }
            }

            FileStatistics Stat = await AssertConsistent(this.file, this.provider, null, null, true);

            AssertEx.Same(0, this.file.Count);
            AssertEx.Same(1, Stat.NrBlocks);
            AssertEx.Same(0, Stat.NrBlobBlocks);
        }
Ejemplo n.º 14
0
        private async Task TestMultiple(int NrObjects, int ArraySize, int BulkSize, bool AssertIndividually, int?LogStatisticsEvery)
        {
            DateTime Start = DateTime.Now;
            List <FileStatistics> Stat = null;
            List <double>         Milliseconds = null;
            int i = 0, j;

            Simple[]         Objects = new Simple[NrObjects];
            Simple[]         Block   = new Simple[ArraySize];
            Simple           Obj2;
            ObjectSerializer Serializer = this.provider.GetObjectSerializerEx(typeof(Simple));

            if (BulkSize > 1)
            {
                await this.provider.StartBulk();
            }

            while (i < NrObjects)
            {
                for (j = 0; j < ArraySize; j++)
                {
                    Block[j]     = CreateSimple(this.MaxStringLength);
                    Objects[i++] = Block[j];
                }

                if (ArraySize > 1)
                {
                    await this.file.SaveNewObjects(Block, Serializer);
                }
                else
                {
                    await this.file.SaveNewObject(Block[0]);
                }

                if (BulkSize > 1 && i % BulkSize == 0)
                {
                    await this.provider.EndBulk();

                    await this.provider.StartBulk();
                }

                if (AssertIndividually)
                {
                    Console.Out.WriteLine();
                    Console.Out.WriteLine(i.ToString() + " objects:");
                    Console.Out.WriteLine(new string('-', 80));

                    await AssertConsistent(this.file, this.provider, i, Objects[i - 1], true);
                }

                if (LogStatisticsEvery.HasValue && i % LogStatisticsEvery.Value == 0)
                {
                    if (Stat is null)
                    {
                        Milliseconds = new List <double>();
                        Stat         = new List <FileStatistics>();
                    }

                    Milliseconds.Add((DateTime.Now - Start).TotalMilliseconds / LogStatisticsEvery.Value);
                    Stat.Add((await this.file.ComputeStatistics()).Key);

                    Start = DateTime.Now;
                }
            }

            if (BulkSize > 1)
            {
                await this.provider.EndBulk();
            }

            for (i = 0; i < NrObjects; i++)
            {
                Obj2 = await this.file.LoadObject <Simple>(Objects[i].ObjectId);

                DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj2);
            }

            if (!AssertIndividually)
            {
                await AssertConsistent(this.file, this.provider, NrObjects, null, true);
            }

            if (Stat != null)
            {
                Variables v = new Variables()
                {
                    { "Stat", Stat.ToArray() },
                    { "ms", Milliseconds.ToArray() },
                    { "StepSize", LogStatisticsEvery.Value }
                };

                Expression Exp = new Expression("[ms,Stat.BlockSize,Stat.NrBlocks,Stat.NrBytesUsed,Stat.NrBytesUnused,Stat.NrBytesTotal," +
                                                "Stat.Usage,Stat.NrObjects,Stat.MinObjectSize,Stat.MaxObjectSize,Stat.AverageObjectSize,Stat.MinDepth,Stat.MaxDepth," +
                                                "Stat.NrBlockLoads,Stat.NrCacheLoads,Stat.NrBlockSaves,Stat.MinObjectsPerBlock,Stat.MaxObjectsPerBlock," +
                                                "Stat.AverageObjectsPerBlock,Stat.MinBytesUsedPerBlock,Stat.MaxBytesUsedPerBlock,Stat.AverageBytesUsedPerBlock]T");

                Console.Out.WriteLine("ms, BlockSize, NrBlocks, NrBytesUsed, NrBytesUnused, NrBytesTotal, " +
                                      "Usage, NrObjects, MinObjectSize, MaxObjectSize, AverageObjectSize, MinDepth, MaxDepth, " +
                                      "NrBlockLoads, NrCacheLoads, NrBlockSaves,Min(Obj/Block),Max(Obj/Block),Avg(Obj/Block)," +
                                      "Min(UsedBytes/Block),Max(UsedBytes/Block),Avg(UsedBytes/Block)");
                Console.Out.WriteLine(new string('-', 80));
                Console.Out.WriteLine(Exp.Evaluate(v).ToString());
            }
        }