Ejemplo n.º 1
0
        public static void Benchmark()
        {
            var gameObjects = SceneManager
                              .GetActiveScene()
                              .GetRootGameObjects()
                              .SelectMany(x => x.RootWithChildren())
                              .ToList();

            PrefabsAnalysis.Reset();

            using (SimpleWatch.New(ms => Debug.Log($"Analysis finished in {ms} ms.")))
                foreach (var gameObject in gameObjects)
                {
                    PrefabsAnalysis.Execute(gameObject);
                }
        }
Ejemplo n.º 2
0
        public async Task TestCtor(string url, int timeout)
        {
            var req = HttpReq.Get(url).Timeout(timeout * 1000);

            var time = await SimpleWatch.DoAsync(async() => await req.SendAsync());

            _output.WriteLine("耗时:" + time.TimeSpan.TotalSeconds + "秒");
            if (time.Ret.HasError)
            {
                _output.WriteLine("异常类型:" + time.Ret.Exception.GetInnermost().GetType());
                if (time.Ret.Exception is WebException e && e.Status == WebExceptionStatus.Timeout)
                {
                    Assert.True(time.TimeSpan.TotalSeconds > timeout &&
                                time.TimeSpan.TotalSeconds < timeout + 1);
                }
            }
        }
Ejemplo n.º 3
0
        public static async ValueTask RawTest(IHttpService service, IList <HttpReq> reqs, int rounds)
        {
            var before = GC.GetTotalMemory(true);
            var t      = await SimpleWatch.DoAsync(async() =>
            {
                for (var i = 0; i < rounds; i++)
                {
                    foreach (var req in reqs)
                    {
                        var res = await service.ExecuteAsync(req).DonotCapture();
                        res.ThrowIfError();
                    }
                }
            }).DonotCapture();

            var after = GC.GetTotalMemory(true);

            Console.WriteLine($"[{service.GetType().SimpleName()}]: " +
                              $"Round: {rounds}, " +
                              $"Time: {t.TotalSeconds:f2}s, " +
                              $"Memory: {after - before}byte");
        }