Exemplo n.º 1
0
        public void BenchmarkZoneMapFfxi()
        {
            string mapName   = SetupPersister.GetCurrentMethodName();
            var    persister = new FilePersister(mapName);
            var    want      = SetupZoneMap.SetupFfxiSizeGrid();
            // Path assumes to start from ./debug/ so we want to set it to the test fixtures dir.
            string grandParentDirectory = Directory.GetParent(persister.FilePath).FullName;
            string parentDirectory      = Directory.GetParent(grandParentDirectory).FullName;

            persister.FilePath = Path.Combine(parentDirectory, "fixtures");

            int time = Benchmark.Run("StreamReader.ReadToEnd", 5, () =>
            {
                persister.Save(want);
                var got = persister.Load <ZoneMap>();
                persister.Delete();
            });

            int benchTime = 1200;

            // Best time so far: 23548ms
            // New record!:      10214ms
            Assert.True(time < benchTime,
                        "time per iteration was: " + time + "ms which is greater than expected time of: " + benchTime + "ms");
        }