Exemplo n.º 1
0
        private void PrintHelp(NotParsed <object> result)
        {
            PerformanceTesting.Checkpoint("Begin Help");
            var verb = GetVerb(result.TypeInfo.Current);

            HelpPrinter.PrintHelp(verb, result);
        }
Exemplo n.º 2
0
 public void WriteThroughput()
 {
     PerformanceTesting.TestWrite(
         size: TestDataSize.Large,
         output: w => new GZipOutputStream(w)
         );
 }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            using (var redis = new RedisClient()) {
                // Performance to Test
                // Adding full list to redis
                // Get all indexes as a time table
                // want to see how time changes for different items in the list

                redis.FlushDb();
                var data = new MockedData(300000);

                var list = new RedisList(Guid.NewGuid().ToString(), redis, data);
                var set  = new RedisSortedSet(Guid.NewGuid().ToString(), redis, data);

                Console.WriteLine("List Testing");
                PerformanceTesting.TimeOperation("Insert all data into a list", list.AddAllRecords);
                PerformanceTesting.TimeOperation("Lookup all records sequentially - one by one", list.LookupRecordsSequentially);

                Console.WriteLine("++++++++++============================================++++++++++");

                Console.WriteLine("Sorted Set Testing");
                PerformanceTesting.TimeOperation("Insert all data into a sortedset", set.AddAllRecords);
                PerformanceTesting.TimeOperation("Lookup all records sequentially - one by one", set.LookupRecordsSequentially);
            }
        }
Exemplo n.º 4
0
        public void SingleLargeEntry()
        {
            const string       EntryName = "LargeTarEntry";
            const TestDataSize dataSize  = TestDataSize.Large;

            PerformanceTesting.TestReadWrite(
                size: dataSize,
                input: bs =>
            {
                var tis   = new TarInputStream(bs, null);
                var entry = tis.GetNextEntry();

                Assert.AreEqual(EntryName, entry.Name);
                return(tis);
            },
                output: bs =>
            {
                var tos = new TarOutputStream(bs, null);
                tos.PutNextEntry(new TarEntry(new TarHeader()
                {
                    Name = EntryName,
                    Size = (int)dataSize,
                }));
                return(tos);
            },
                outputClose: stream =>
            {
                ((TarOutputStream)stream).CloseEntry();
            }
                );
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");
            var configuration   = builder.Build();
            var redisConnection = configuration["RedisConnection"];

            var redis = ConnectionMultiplexer.Connect(redisConnection);

            FlushAllDbs(redisConnection);

            var cache = redis.GetDatabase();
            var data  = new MockedData(500000);

            var list = new RedisList(Guid.NewGuid().ToString(), cache, data);

            // var set = new RedisSortedSet (Guid.NewGuid ().ToString (), cache, data);

            Console.WriteLine("List Testing");
            PerformanceTesting.TimeOperation("Insert all data into a list", list.AddAllRecords);
            PerformanceTesting.TimeOperation("Lookup all records sequentially - one by one", list.LookupRecord);

            Console.WriteLine("++++++++++============================================++++++++++");

            Console.WriteLine($"Removing list id: {list.Identifier}");
            cache.KeyDelete(list.Identifier);

            //     Console.WriteLine ("Sorted Set Testing");
            //     PerformanceTesting.TimeOperation ("Insert all data into a sorted set", set.AddAllRecords);
            //     PerformanceTesting.TimeOperation ("Lookup all records sequentially - one by one", set.LookupRecordsSequentially);
        }
Exemplo n.º 6
0
 public void WriteThroughput()
 {
     PerformanceTesting.TestWrite(
         size: TestDataSize.Small,
         output: w => new BZip2OutputStream(w)
         );
 }
Exemplo n.º 7
0
        public static ProcessResult Run(string command, string arguments, string workingDirectory, bool printOutput, bool printErrors)
        {
            try
            {
                Output.Logger.Debug("starting child process", new { command, arguments, workingDirectory });
                PerformanceTesting.Checkpoint($"Begin Process {command} {arguments.Split(' ').First()}");

                var process = System.Diagnostics.Process.Start(new ProcessStartInfo()
                {
                    FileName               = command,
                    WorkingDirectory       = workingDirectory ?? Environment.CurrentDirectory,
                    Arguments              = arguments,
                    RedirectStandardOutput = !printOutput,
                    RedirectStandardError  = !printErrors,
                });
                process.WaitForExit();

                var output = printOutput ? null : process.StandardOutput.ReadToEnd();
                var error  = printErrors ? null : process.StandardError.ReadToEnd();

                Output.Logger.Trace("end child process", new { command, arguments, workingDirectory, process_stdout = output, process_stderr = error });

                PerformanceTesting.Checkpoint($"End Process {command}");
                return(new ProcessResult(process.ExitCode, output, error));
            }
            catch (Win32Exception ex)
            {
                Output.Logger.Fatal("missing dependency", new { dependency = command });
                throw new FatalException($"{command} is not available.", ex);
            }
        }
Exemplo n.º 8
0
        private void ExecuteVerb(IOptions options)
        {
            PerformanceTesting.Checkpoint("End Parse");
            options.PassthroughArguments = string.Join(" ", _argsRest);

            var verb = GetVerb(options.GetType());

            VerbExecuter.ExecuteVerb(verb, options);
        }
Exemplo n.º 9
0
        public static void InitUserConfig(ILogger logger)
        {
            PerformanceTesting.Checkpoint("Begin Configuration");

            logger.Debug("building user configuration");
            UserConfig = BuildUserConfig();

            PerformanceTesting.Checkpoint("End Configuration");
        }
Exemplo n.º 10
0
 public void WriteThroughput()
 {
     PerformanceTesting.TestWrite(0x10000000, bs =>
     {
         var zos = new ZipOutputStream(bs);
         zos.PutNextEntry(new ZipEntry("0"));
         return(zos);
     });
 }
Exemplo n.º 11
0
        private static void CheckDocker(ILogger logger, IVerb verb, UserConfig config)
        {
            PerformanceTesting.Checkpoint("Begin Docker Check");
            logger.Trace("checking docker");

            if (verb.RequiresDocker && config.Checks.Docker && !Docker.IsRunning())
            {
                logger.Fatal("docker check failed");
                throw new FatalException("Docker daemon is unreachable or not running.");
            }

            PerformanceTesting.Checkpoint("End Docker Check");
        }
Exemplo n.º 12
0
        public static void ExecuteVerb(IVerb verb, IOptions options)
        {
            var logger = Init(verb, options);

            logger.Debug("executing verb");

            PerformanceTesting.Checkpoint("Begin Verb");
            verb.Execute(options, Output.Logger);

            logger.Info("execution completed", new { time = PerformanceTesting.GetElapsedMilliseconds() });

            Output.Dispose();
        }
Exemplo n.º 13
0
        public IEnumerable <Error> ParseAndExecuteVerb()
        {
            PerformanceTesting.Checkpoint("Begin Parse");
            switch (GetParser().ParseArguments(_args, GetVerbTypes()))
            {
            case Parsed <object> result:
                ExecuteVerb((IOptions)result.Value);
                break;

            case NotParsed <object> result:
                PrintHelp(result);
                return(result.Errors);
            }
            return(new Error[0]);
        }
Exemplo n.º 14
0
 public static int Main(string[] args)
 {
     try
     {
         PreRun();
         return(Run(args));
     }
     catch (Exception ex)
     {
         return(HandleException(ex));
     }
     finally
     {
         Output.Fancy.ResetStyling();
         PerformanceTesting.Checkpoint("End");
     }
 }
Exemplo n.º 15
0
        public void WriteThroughput()
        {
            const string EntryName = "LargeTarEntry";

            PerformanceTesting.TestWrite(TestDataSize.Large, bs =>
            {
                var tos = new TarOutputStream(bs, null);
                tos.PutNextEntry(new TarEntry(new TarHeader()
                {
                    Name = EntryName,
                    Size = (int)TestDataSize.Large,
                }));
                return(tos);
            },
                                         stream =>
            {
                ((TarOutputStream)stream).CloseEntry();
            });
        }
Exemplo n.º 16
0
        private static int HandleException(Exception ex)
        {
            if (ex is FatalException fatalEx)
            {
                PerformanceTesting.Checkpoint("Fatal Exception");
                ErrorPrinter.Fatal(fatalEx.Message);

                if (fatalEx.InnerException != null)
                {
                    ErrorPrinter.HandledException(null, fatalEx.InnerException);
                }

                return(fatalEx.ExitCode);
            }

            PerformanceTesting.Checkpoint("Unhandled Exception");

            Output.Logger.Fatal(null, ex);
            ErrorPrinter.UnhandledException(ex);

            return(1);
        }
Exemplo n.º 17
0
        public void SingleLargeEntry()
        {
            const string EntryName = "CantSeek";

            PerformanceTesting.TestReadWrite(
                size: TestDataSize.Large,
                input: bs =>
            {
                var zis   = new ZipInputStream(bs);
                var entry = zis.GetNextEntry();

                Assert.AreEqual(entry.Name, EntryName);
                Assert.IsTrue((entry.Flags & (int)GeneralBitFlags.Descriptor) != 0);
                return(zis);
            },
                output: bs =>
            {
                var zos = new ZipOutputStream(bs);
                zos.PutNextEntry(new ZipEntry(EntryName));
                return(zos);
            }
                );
        }
Exemplo n.º 18
0
        private static void PreRun()
        {
            var printPerformanceCheckpoints = Environment.GetEnvironmentVariable("BLENT_PERF_TEST") == "true";

            PerformanceTesting.Begin(printPerformanceCheckpoints);
        }