Esempio n. 1
0
        static void Main(string[] args)
        {
            var options = new Options();

            if (!Parser.Default.ParseArguments(args, options, (t, o) => { target = t; targetOptions = o as CommonOptions; }))
            {
                Console.WriteLine(new CommonOptions().GetUsage());
                Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
            }

            BenchmarkRunner.DefaultTotalSeconds = targetOptions.Seconds;
            BenchmarkRunner.DefaultMaxThreads   = targetOptions.MaxThreads;

            //Metric.Config.WithHttpEndpoint("http://localhost:1234/");

            switch (target)
            {
            case "noop":
                BenchmarkRunner.Run("Noop", () => { });
                break;

            case "counter":
                var counter = new CounterMetric();
                BenchmarkRunner.Run("Counter", () => counter.Increment());
                break;

            case "meter":
                var meter = new MeterMetric();
                BenchmarkRunner.Run("Meter", () => meter.Mark());
                break;

            case "histogram":
                var histogram = new HistogramMetric();
                BenchmarkRunner.Run("Histogram", () => histogram.Update(137));
                break;

            case "timer":
                var timer = new TimerMetric();
                BenchmarkRunner.Run("Timer", () => timer.Record(1, TimeUnit.Milliseconds));
                break;

            case "hdrtimer":
                var hdrTimer = new TimerMetric(new HdrHistogramReservoir());
                BenchmarkRunner.Run("HDR Timer", () => hdrTimer.Record(1, TimeUnit.Milliseconds));
                break;

            case "ewma":
                var ewma = EWMA.OneMinuteEWMA();
                BenchmarkRunner.Run("EWMA", () => ewma.Update(1));
                break;

            case "edr":
                var edr = new ExponentiallyDecayingReservoir();
                BenchmarkRunner.Run("EDR", () => edr.Update(1));
                break;

            case "hdr":
                var hdrReservoir = new HdrHistogramReservoir();
                BenchmarkRunner.Run("HDR Recorder", () => hdrReservoir.Update(1));
                break;

            case "uniform":
                var uniform = new UniformReservoir();
                BenchmarkRunner.Run("Uniform", () => uniform.Update(1));
                break;

            case "sliding":
                var sliding = new SlidingWindowReservoir();
                BenchmarkRunner.Run("Sliding", () => sliding.Update(1));
                break;

            case "timerimpact":
                var load = new WorkLoad();
                BenchmarkRunner.Run("WorkWithoutTimer", () => load.DoSomeWork(), iterationsChunk: 10);
                BenchmarkRunner.Run("WorkWithTimer", () => load.DoSomeWorkWithATimer(), iterationsChunk: 10);
                break;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var options = new Options();

            if (!Parser.Default.ParseArguments(args, options, (t, o) => { target = t; targetOptions = o as CommonOptions; }))
            {
                Console.WriteLine(new CommonOptions().GetUsage());
                Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
            }

            Console.WriteLine("{0} | Duration {1} seconds  | Start Threads {2} | Step {3}", target, targetOptions.Seconds, targetOptions.MaxThreads, targetOptions.Decrement);


            switch (target)
            {
            case "counter":
                Run(() => new CounterMetric(), c => c.Increment());
                break;

            case "meter":
                Run(() => new MeterMetric(), m => m.Mark());
                break;

            case "histogram":
                Run(() => new HistogramMetric(), h => h.Update(37));
                break;

            case "timer":
                Run(() => new TimerMetric(SamplingType.FavourRecent), t => t.Record(10, TimeUnit.Milliseconds));
                break;

            case "ewma":
                Run(() => EWMA.OneMinuteEWMA(), m => m.Update(1));
                break;

            case "edr":
                Run(() => new ExponentiallyDecayingReservoir(), r => r.Update(100));
                break;

            case "uniform":
                Run(() => new UniformReservoir(), r => r.Update(100));
                break;

            case "sliding":
                Run(() => new SlidingWindowReservoir(), r => r.Update(100));
                break;
            }
        }