Exemplo n.º 1
0
        public void BedrockChunkLoadTest()
        {
            int   count          = 0;
            ulong totalSize      = 0;
            var   chunks         = GenerateChunks(new ChunkCoordinates(0, 0), 18).OrderBy(kvp => kvp.Value).ToArray();
            int   numberOfChunks = chunks.Length;
            var   hierarchy      = (Hierarchy)LogManager.GetRepository(Assembly.GetEntryAssembly());

            hierarchy.Root.Level = Level.Info;

            using var db = new Database(new DirectoryInfo("benchmark.mcworld"));
            db.Open();

            Assert.IsTrue(BitConverter.IsLittleEndian);

            var sw = Stopwatch.StartNew();

            while (count < numberOfChunks)
            {
                foreach (var pair in chunks)
                {
                    if (count >= numberOfChunks)
                    {
                        break;
                    }

                    ChunkCoordinates coordinates = pair.Key;

                    byte[] index = Combine(BitConverter.GetBytes(coordinates.X), BitConverter.GetBytes(coordinates.Z));

                    byte[] version = db.Get(Combine(index, 0x76));

                    byte[] chunkDataKey = Combine(index, new byte[] { 0x2f, 0 });
                    for (byte y = 0; y < 16; y++)
                    {
                        chunkDataKey[^ 1] = y;