Пример #1
0
        static void Main(string[] args)
        {
            // Create the test runner. Configure it to run lots of tests in parallel.
            var tester = new TestRunner
            {
                ParallelTests = 128
            };

            // Get a chunk of data
            var data = MakeData();

            // Test how fast we can copy that data
            tester.AddTest(() => {
                var dataCopy = new byte[data.Length];
                data.CopyTo(dataCopy, 0);

                // This test can not fail, so always report success.
                return true;
            });

            // Run the test
            tester.Start();

            // Print status information every second
            while(true)
            {
                Thread.Sleep(1000);
                Console.WriteLine(String.Format(
                    "Requests: {0} ({1:0.00}/s), Errors: {2} ({3:0.00}%), ",
                    tester.TotalTestsExecuted,
                    tester.TotalTestsExecuted / tester.TotalSeconds,
                    tester.TotalErrors,
                    100.0 * (double)tester.TotalErrors / tester.TotalTestsExecuted
                ));
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var options = new Options();
            var ids = new[] { "20702362", "8791176", "19426582", "25969427", "19875072", "17413827", "4238394", "19999983", "24926433", "3771061", "3260133", "6969727", "7402881", "3189164", "5659077", "22838624", "7514760", "7293646", "4792995", "6264180", "18046522", "2662465", "4742592", "6246942", "25893775", "24050407", "21433818", "144350", "4413963", "19578541", "6046979", "3213902" };

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
                return;

            Provider data = null;
            SimpleClient client = null;

            if (string.IsNullOrEmpty(options.HttpUrl))
            {
                data = new Provider();
            }
            else
            {
                client = new SimpleClient(options.HttpUrl);
            }

            var fSingle = string.IsNullOrEmpty(options.HttpUrl)
                ? new Func<string, string, string, Task<List<string>>>( async (appid, item, rel) => await data.Get(appid, item, rel))
                : new Func<string, string, string, Task<List<string>>>( async (appid, item, rel) => await client.GetAsync(item, rel));

            var runner = new TestRunner(options.ThreadCount, Console.Out);
            runner.SlaTarget = options.Sla;

            if (options.IstracingEnabled)
                runner.Log = LogManager.GetLogger("TestRunner");

            runner.AddPlan(new TestPlan("warmup",
                options.IterationsCount,
                counter =>
                {
                    var res = fSingle(options.ApplicationId, ids[counter % 10], "vv").Result;
                    if (res == null)
                        throw new ArgumentNullException();
                }) { IsWarmUp = true });

            if (options.DoSingle)
            {
                runner.AddPlan("vv single",
                    options.IterationsCount,
                    counter =>
                    {
                        var res = fSingle(options.ApplicationId, ids[counter % 10], "vv").Result;
                        if (res == null)
                            throw new ArgumentNullException();
                    });
            }

            var i = fSingle("ozon", ids[0], "vv").Result;
            if (i == null)
                return;

            runner.Start();
            var opts = ReportOptions.None;
            if (options.ReportTotals)
                opts = opts | ReportOptions.Totals;
            if (options.ReportSlowest)
                opts = opts | ReportOptions.Slowest;
            runner.Report(opts);
        }