Beispiel #1
0
        /// <summary>
        /// Consumes passed argument.
        /// </summary>
        /// <param name="name">Argument name.</param>
        /// <param name="val">Value.</param>
        /// <returns>True if argument was consumed.</returns>
        public void Configure(string name, string val)
        {
            var prop = BenchmarkUtils.GetProperty(this, name);

            if (prop != null)
            {
                BenchmarkUtils.SetProperty(this, prop, val);
            }
        }
        /// <summary>
        /// Entry point.
        /// </summary>
        /// <param name="args">Arguments.</param>
        // ReSharper disable once RedundantAssignment
        public static void Main(string[] args)
        {
            args = new[] {
                //typeof(GetAllBenchmark).FullName,
                typeof(GetAllBinaryBenchmark).FullName,
                //typeof(ThinClientGetAllBenchmark).FullName,
                //typeof(ThinClientGetAllBinaryBenchmark).FullName,
                "-ConfigPath", Directory.GetCurrentDirectory() + @"\..\..\Config\benchmark.xml",
                "-Threads", "1",
                "-Warmup", "0",
                "-Duration", "60",
                "-BatchSize", "1"
            };

            var gcSrv = System.Runtime.GCSettings.IsServerGC;

            Console.WriteLine("GC Server: " + gcSrv);

            if (!gcSrv)
            {
                Console.WriteLine("WARNING! GC server mode is disabled. This could yield in bad preformance.");
            }

            Console.WriteLine("DotNet benchmark process started: " + Process.GetCurrentProcess().Id);

            var argsStr = new StringBuilder();

            foreach (var arg in args)
            {
                argsStr.Append(arg + " ");
            }

            if (args.Length < 1)
            {
                throw new Exception("Not enough arguments: " + argsStr);
            }

            Console.WriteLine("Arguments: " + argsStr);

            var benchmarkType = Type.GetType(args[0]);

            if (benchmarkType == null)
            {
                throw new InvalidOperationException("Could not find benchmark type: " + args[0]);
            }

            var benchmark = (BenchmarkBase)Activator.CreateInstance(benchmarkType);

            for (var i = 1; i < args.Length; i++)
            {
                var arg = args[i];

                if (arg.StartsWith("-"))
                {
                    arg = arg.Substring(1);
                }
                else
                {
                    continue;
                }

                var prop = BenchmarkUtils.GetProperty(benchmark, arg);

                if (prop != null)
                {
                    benchmark.Configure(prop.Name, prop.PropertyType == typeof(bool) ? bool.TrueString : args[++i]);
                }
            }

            benchmark.Run();

#if (DEBUG)
            Console.ReadLine();
#endif
        }
Beispiel #3
0
        /// <summary>
        /// Entry point.
        /// </summary>
        /// <param name="args">Arguments.</param>
        // ReSharper disable once RedundantAssignment
        public static void Main(string[] args)
        {
#if (DEBUG)
            throw new Exception("Don't run benchmarks in Debug mode");
#endif
#pragma warning disable 162
            // ReSharper disable HeuristicUnreachableCode

            args = new[] {
                //typeof(GetAllBenchmark).FullName,
                typeof(PutWithPlatformCacheBenchmark).FullName,
                //typeof(ThinClientGetAllBenchmark).FullName,
                //typeof(ThinClientGetAllBinaryBenchmark).FullName,
                "-ConfigPath", GetConfigPath(),
                "-Threads", "1",
                "-Warmup", "5",
                "-Duration", "30",
                "-BatchSize", "1"
            };

            var gcSrv = System.Runtime.GCSettings.IsServerGC;

            Console.WriteLine("GC Server: " + gcSrv);

            if (!gcSrv)
            {
                Console.WriteLine("WARNING! GC server mode is disabled. This could yield in bad performance.");
            }

            Console.WriteLine("DotNet benchmark process started: " + Process.GetCurrentProcess().Id);

            var argsStr = new StringBuilder();

            foreach (var arg in args)
            {
                argsStr.Append(arg + " ");
            }

            if (args.Length < 1)
            {
                throw new Exception("Not enough arguments: " + argsStr);
            }

            Console.WriteLine("Arguments: " + argsStr);

            var benchmarkType = Type.GetType(args[0]);

            if (benchmarkType == null)
            {
                throw new InvalidOperationException("Could not find benchmark type: " + args[0]);
            }

            var benchmark = (BenchmarkBase)Activator.CreateInstance(benchmarkType);

            for (var i = 1; i < args.Length; i++)
            {
                var arg = args[i];

                if (arg.StartsWith("-", StringComparison.Ordinal))
                {
                    arg = arg.Substring(1);
                }
                else
                {
                    continue;
                }

                var prop = BenchmarkUtils.GetProperty(benchmark, arg);

                if (prop != null)
                {
                    benchmark.Configure(prop.Name, prop.PropertyType == typeof(bool) ? bool.TrueString : args[++i]);
                }
            }

            benchmark.Run();
#pragma warning restore 162
        }