Ejemplo n.º 1
0
        public IEnumerator PerfTest()
        {
            SceneMergeTests.CloseAllUniMergeWindows();

            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
            UnityEngine.Random.InitState(0);
            const int objectCount = 2500;
            var       mine        = FillScene.GenerateObjects(objectCount);
            var       theirs      = FillScene.GenerateObjects(objectCount);
            var       objectMerge = EditorWindow.GetWindow <ObjectMerge>();

            objectMerge.Show();

            objectMerge.root.mine   = mine;
            objectMerge.root.theirs = theirs;

            while (objectMerge.update != null)
            {
                yield return(null);
            }

            objectMerge.update = objectMerge.root.Copy(true);

            while (objectMerge.update != null)
            {
                yield return(null);
            }

            Assert.That(objectMerge.root.Same);
            // Note: The SceneMerge and ObjectMerge windows won't show all green becasue of the Undo which is applied after tests

            SceneMergeTests.CloseAllUniMergeWindows();
        }
Ejemplo n.º 2
0
        public void PerfTest()
        {
            SceneMergeTests.CloseAllUniMergeWindows();

            var       trials     = new List <long>();
            const int trialCount = 10;

            for (var i = 0; i < trialCount; i++)
            {
                EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
                UnityEngine.Random.InitState(0);
                const int objectCount = 1000;
                var       mine        = FillScene.GenerateObjects(objectCount);
                var       theirs      = FillScene.GenerateObjects(objectCount);
                var       objectMerge = EditorWindow.GetWindow <ObjectMerge>();
                objectMerge.Show();

                var root = objectMerge.root;
                root.SetGameObjects(mine, theirs);

                while (objectMerge.IsUpdating())
                {
                    if (!objectMerge.UpdateMoveNext())
                    {
                        objectMerge.update = null;
                    }
                }

                GC.Collect();
                stopwatch.Reset();
                stopwatch.Start();
                var enumerator = root.Copy(true);
                while (enumerator.MoveNext())
                {
                }

                stopwatch.Stop();
                trials.Add(stopwatch.Elapsed.Ticks);

                Assert.That(root.Same);
                // Note: The SceneMerge and ObjectMerge windows won't show all green because of the Undo which is applied after tests

                SceneMergeTests.CloseAllUniMergeWindows();
            }

            var average = trials.Average();

            Debug.Log(string.Format("Average: {0}", new TimeSpan((long)average)));
            var stdDev = CalculateStdDev(trials);

            Debug.Log(string.Format("StDev: {0:0.0%} {1}", stdDev / average, new TimeSpan((long)stdDev)));
        }