Exemplo n.º 1
0
        public IActionResult LoadTestAsync(int requestCount, string cacheKey, string authorization)
        {
            bool       success   = true;
            CacheEntry result    = null;
            var        completed = 0;

            var watch = Stopwatch.StartNew();

            for (int i = 0; i < requestCount; i++)
            {
                var t = new Thread(() =>
                {
                    result = TestsBL.TestGet(out success, cacheKey, authorization);
                    completed++;
                    if (completed == requestCount)
                    {
                        watch.Stop();
                    }
                });
                t.Start();
            }

            while (completed < requestCount)
            {
                Thread.Sleep(10);
            }

            return(Ok(new
            {
                message = $"{requestCount} requests in {watch.ElapsedMilliseconds}ms",
                result
            }));
        }
Exemplo n.º 2
0
        public IActionResult Test()
        {
            var result = TestsBL.TestPost(out bool success, "a");

            result = TestsBL.TestPost(out success, "b");
            return(Ok(new { result }));
        }
Exemplo n.º 3
0
        public IActionResult LoadTestSync(int requestCount, string cacheKey, string authorization)
        {
            bool       success = true;
            CacheEntry result  = null;
            var        watch   = Stopwatch.StartNew();

            for (int i = 0; i < requestCount; i++)
            {
                result = TestsBL.TestGet(out success, cacheKey, authorization);
            }
            watch.Stop();
            return(Ok(new
            {
                message = $"{requestCount} requests in {watch.ElapsedMilliseconds}ms",
                result
            }));
        }