public unsafe void PerformanceTest_NodeParser_Step_MockEntities(int count)
        {
            var json = JsonTestData.GetMockEntities(count);

            fixed(char *ptr = json)
            {
                m_Tokenizer.Write(new UnsafeBuffer <char>(ptr, json.Length), 0, json.Length);
            }

            Measure.Method(() =>
            {
                using (var parser = new NodeParser(m_Tokenizer, Allocator.TempJob))
                {
                    parser.Step(NodeType.None);
                }
            })
            .WarmupCount(1)
            .MeasurementCount(100)
            .Run();

            PerformanceTest.Active.CalculateStatisticalValues();

            var size = json.Length / (double)1024 / 1024;

            Debug.Log($"MB/s=[{size / (PerformanceTest.Active.SampleGroups.First().Median / 1000)}]");
        }
        public unsafe void PerformanceTest_PackedBinaryWriter_Write_MockEntities(int count)
        {
            var json = JsonTestData.GetMockEntities(count);

            fixed(char *ptr = json)
            {
                m_Tokenizer.Write(new UnsafeBuffer <char>(ptr, json.Length), 0, json.Length);
            }

            Measure.Method(() =>
            {
                using (var stream = new PackedBinaryStream(Allocator.TempJob))
                    using (var writer = new PackedBinaryWriter(stream, m_Tokenizer, Allocator.TempJob))
                    {
                        fixed(char *ptr = json)
                        {
                            writer.Write(new UnsafeBuffer <char>(ptr, json.Length), m_Tokenizer.TokenNextIndex);
                        }
                    }
            })
            .WarmupCount(1)
            .MeasurementCount(100)
            .Run();

            PerformanceTest.Active.CalculateStatisticalValues();

            var size = json.Length / (double)1024 / 1024;

            Debug.Log($"MB/s=[{size / (PerformanceTest.Active.SampleGroups.First().Median / 1000)}]");
        }
        public unsafe void DeserializeFromFile_UsingSerializedObjectReaderWithNoActualization_MockEntityData(int count, int batchSize)
        {
            File.WriteAllText("test.json", JsonTestData.GetMockEntities(count));

            try
            {
                Measure.Method(() =>
                {
                    var views  = stackalloc SerializedValueView[batchSize];
                    var config = SerializedObjectReaderConfiguration.Default;

                    config.UseReadAsync     = false;
                    config.ValidationType   = JsonValidationType.None;
                    config.NodeBufferSize   = batchSize;
                    config.BlockBufferSize  = 512 << 10;
                    config.OutputBufferSize = 4096 << 10;

                    using (var stream = new FileStream("test.json", FileMode.Open, FileAccess.Read, FileShare.Read, config.BlockBufferSize))
                        using (var reader = new SerializedObjectReader(stream, config))
                        {
                            reader.Step(NodeType.BeginArray);

                            while (reader.ReadArrayElementBatch(views, batchSize) != 0)
                            {
                                reader.DiscardCompleted();
                            }

                            reader.Step();
                        }
                })
                .WarmupCount(1)
                .MeasurementCount(100)
                .Run();

                PerformanceTest.Active.CalculateStatisticalValues();

                var size = new FileInfo("test.json").Length / (double)1024 / 1024;
                Debug.Log($"MB/s=[{size / (PerformanceTest.Active.SampleGroups.First().Median / 1000)}]");
            }
            finally
            {
                File.Delete("test.json");
            }
        }
        public void DeserializeFromFile_UsingJsonUtility_MockEntityData(int count)
        {
            File.WriteAllText("test.json", JsonTestData.GetMockEntities(count));

            try
            {
                Measure.Method(() => { UnityEngine.JsonUtility.FromJson <MockEntityBatch>(File.ReadAllText("test.json")); })
                .WarmupCount(1)
                .MeasurementCount(100)
                .Run();

                PerformanceTest.Active.CalculateStatisticalValues();

                var size = new FileInfo("test.json").Length / (double)1024 / 1024;
                Debug.Log($"MB/s=[{size / (PerformanceTest.Active.SampleGroups.First().Median / 1000)}]");
            }
            finally
            {
                File.Delete("test.json");
            }
        }
Esempio n. 5
0
        public unsafe void PerformanceTest_JsonValidatorSimple_Validate_MockEntities(int count)
        {
            var json = JsonTestData.GetMockEntities(count);

            Measure.Method(() =>
            {
                fixed(char *ptr = json)
                {
                    using (var validator = new JsonValidator(JsonValidationType.Simple, Allocator.TempJob))
                    {
                        validator.Validate(new UnsafeBuffer <char>(ptr, json.Length), 0, json.Length);
                    }
                }
            })
            .WarmupCount(1)
            .MeasurementCount(100)
            .Run();

            PerformanceTest.Active.CalculateStatisticalValues();

            var size = json.Length / (double)1024 / 1024;

            Debug.Log($"MB/s=[{size / (PerformanceTest.Active.SampleGroups.First().Median / 1000)}]");
        }
Esempio n. 6
0
        public unsafe void PerformanceTest_JsonTokenizer_WriteWithStandardValidation_MockEntities(int count, int initialTokenBuffer)
        {
            var json = JsonTestData.GetMockEntities(count);

            Measure.Method(() =>
            {
                fixed(char *ptr = json)
                {
                    using (var tokenizer = new JsonTokenizer(initialTokenBuffer, JsonValidationType.Standard))
                    {
                        tokenizer.Write(new UnsafeBuffer <char>(ptr, json.Length), 0, json.Length);
                    }
                }
            })
            .WarmupCount(1)
            .MeasurementCount(100)
            .Run();

            PerformanceTest.Active.CalculateStatisticalValues();

            var size = json.Length / (double)1024 / 1024;

            Debug.Log($"MB/s=[{size / (PerformanceTest.Active.SampleGroups.First().Median / 1000)}]");
        }