Exemple #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
            }));
        }
Exemple #2
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
            }));
        }