Пример #1
0
 private void DeserializeFromFile()
 {
     // As 2nd parameter "_targetObject" isnt specified, object of new instance is created on deserialization
     // If "_targetObject" was specified then deserialized value would be assigned to the target instance
     SerializationTarget = RSManager.Deserialize <SerializationSample>(Save2FileSerializationID);
 }
Пример #2
0
        private void StartProfiling(TestCase _test)
        {
            Stopwatch _sw = new Stopwatch();

            // Start timer to check performance
            _sw.Start();

            switch (_test)
            {
            case TestCase.BS_SERIALIZATION:
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    PerformBSSerialization <BenchmarkSample>(m_benchmarkSample);
                }
                break;

            case TestCase.BS_DESERIALIZATION:
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    m_benchmarkSample = PerformBSDeserialization <BenchmarkSample>();
                }
                break;

            case TestCase.RS_SERIALIZATION_CLASS:
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    RSManager.Serialize <BenchmarkSample>(m_benchmarkSample, kRuntimeSerializationClassID, eSaveTarget.PLAYER_PREFS);
                }
                break;

            case TestCase.RS_DESERIALIZATION_CLASS:
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    m_benchmarkSample = RSManager.Deserialize <BenchmarkSample>(kRuntimeSerializationClassID);
                }
                break;

            case TestCase.RS_SERIALIZATION_GAMEOBJECT:
#if (UNITY_WEBPLAYER || UNITY_WEBGL)
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    RSManager.Serialize <GameObject>(m_serializeGameObject, kGameobjectSaveID, eSaveTarget.PLAYER_PREFS);
                }
#else
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    RSManager.Serialize <GameObject>(m_serializeGameObject, kGameobjectSaveID, eSaveTarget.FILE_SYSTEM);
                }
#endif
                break;

            case TestCase.RS_DESERIALIZATION_GAMEOBJECT:
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    m_serializeGameObject = RSManager.Deserialize <GameObject>(kGameobjectSaveID);
                }
                break;

            case TestCase.RS_SERIALIZATION_PREFAB:
#if (UNITY_WEBPLAYER || UNITY_WEBGL)
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    RSManager.Serialize <GameObject>(m_serializePrefab, kPrefabSaveID, eSaveTarget.PLAYER_PREFS);
                }
#else
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    RSManager.Serialize <GameObject>(m_serializePrefab, kPrefabSaveID, eSaveTarget.FILE_SYSTEM);
                }
#endif
                break;

            case TestCase.RS_DESERIALIZATION_PREFAB:
                for (int _iter = 0; _iter < m_executionCount; _iter++)
                {
                    m_serializePrefab = RSManager.Deserialize <GameObject>(kPrefabSaveID);
                }
                break;
            }

            // Stop timer
            _sw.Stop();

            m_testResult = string.Format("[PerformanceTester] Execution time for {0}: {1}ms", _test, _sw.ElapsedMilliseconds);
        }