From 70eae64ea4c48195923ea1727fc933b53fe0a5c3 Mon Sep 17 00:00:00 2001 From: JR-Morgan <45512892+JR-Morgan@users.noreply.github.com> Date: Thu, 27 Oct 2022 16:37:04 +0100 Subject: [PATCH] Removed some empty gameobjects that were accidently added to SpecklePlayground scene --- Assets/Tests/Editor/PerformanceTest.cs | 56 +++++++++++++++++++------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/Assets/Tests/Editor/PerformanceTest.cs b/Assets/Tests/Editor/PerformanceTest.cs index e765bdf..7dd600e 100644 --- a/Assets/Tests/Editor/PerformanceTest.cs +++ b/Assets/Tests/Editor/PerformanceTest.cs @@ -1,41 +1,67 @@ using System; +using System.Collections; using System.Diagnostics; using System.Threading.Tasks; using NUnit.Framework; using Speckle.Core.Api; +using UnityEngine; +using UnityEngine.TestTools; public class PerformanceTest { //This method is much faster - // [Test] - // public void PerformanceTestSimplePasses() - // { - // var stopwatch = Stopwatch.StartNew(); - // - // Helpers.Receive("https://latest.speckle.dev/streams/24c3741255/commits/0925840e09").GetAwaiter().GetResult(); - // - // stopwatch.Stop(); - // Console.WriteLine(stopwatch.ElapsedMilliseconds); - // Assert.That(stopwatch.ElapsedMilliseconds, Is.Zero); - // } + private static readonly string[] dataSource = new[] + { + "https://latest.speckle.dev/streams/24c3741255/commits/0925840e09" + }; - //This method takes around 46 seconds to complete - [Test] - public void PerformanceTestSimplePasses() + [Test, TestCaseSource(nameof(dataSource))] + public void Receive_GetAwaiterResult(string stream) + { + var stopwatch = Stopwatch.StartNew(); + + Helpers.Receive(stream).GetAwaiter().GetResult(); + + stopwatch.Stop(); + Console.WriteLine(stopwatch.ElapsedMilliseconds); + Assert.That(stopwatch.ElapsedMilliseconds, Is.Zero); + } + + + //This method takes around 46 seconds to complete + [Test, TestCaseSource(nameof(dataSource))] + public void Receive_TaskRunAsync(string stream) { var stopwatch = Stopwatch.StartNew(); Task.Run(async () => { - await Helpers.Receive("https://latest.speckle.dev/streams/24c3741255/commits/0925840e09"); + await Helpers.Receive(stream); }).GetAwaiter().GetResult(); stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds); Assert.That(stopwatch.ElapsedMilliseconds, Is.Zero); } + + [UnityTest, TestCaseSource(nameof(dataSource))] + public IEnumerable Receive_Coroutine(string stream) + { + var stopwatch = Stopwatch.StartNew(); + + Task t = Helpers.Receive(stream); + t.Start(); + + yield return new WaitUntil(() => !t.IsCompleted || stopwatch.ElapsedMilliseconds >= 100000); + + stopwatch.Stop(); + Console.WriteLine(stopwatch.ElapsedMilliseconds); + Assert.That(stopwatch.ElapsedMilliseconds, Is.Zero); + Assert.True(t.IsCompletedSuccessfully); + } + }