当前位置: 首页>>代码示例>>C#>>正文


C# BenchmarkContext.GetCounter方法代码示例

本文整理汇总了C#中NBench.BenchmarkContext.GetCounter方法的典型用法代码示例。如果您正苦于以下问题:C# BenchmarkContext.GetCounter方法的具体用法?C# BenchmarkContext.GetCounter怎么用?C# BenchmarkContext.GetCounter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NBench.BenchmarkContext的用法示例。


在下文中一共展示了BenchmarkContext.GetCounter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

        public void SetUp(BenchmarkContext context)
        {
            _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName);
            _counterHandlerInbound = new CounterHandlerInbound(_inboundThroughputCounter);
            _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName);
            _counterHandlerOutbound = new CounterHandlerOutbound(_outboundThroughputCounter);

            channel = new EmbeddedChannel(_counterHandlerOutbound, _counterHandlerInbound);
        }
开发者ID:helios-io,项目名称:helios,代码行数:9,代码来源:EmbeddedChannelPerfSpecs.cs

示例2: Setup

 public void Setup(BenchmarkContext context)
 {
     _selectionOpCounter = context.GetCounter(ActorSelectionCounterName);
     System = ActorSystem.Create("MailboxThroughputSpecBase" + Counter.GetAndIncrement());
     _receiver = System.ActorOf(Props.Create(() => new BenchmarkActor(_selectionOpCounter, NumberOfMessages, _resetEvent)));
     _receiverActorPath = _receiver.Path;
     _oneMessageBenchmarkProps = Props.Create(() => new BenchmarkActor(_selectionOpCounter, 1, _resetEvent));
 }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:8,代码来源:ActorSelectionSpecs.cs

示例3: Setup

        public void Setup(BenchmarkContext context)
        {
            _counter = context.GetCounter("TestCounter");

            var fixture = new Fixture();
            fixture.RepeatCount = 100;
            _list = fixture.Create<List<string>>();
            _algorithm = new Algorithm1();
        }
开发者ID:flcdrg,项目名称:IntelliTestAndUnitTesting,代码行数:9,代码来源:AlgorithmPerfSpecs.cs

示例4: Setup

 public void Setup(BenchmarkContext context)
 {
     _createMailboxThroughput = context.GetCounter(CreateThroughputCounter);
     _mailboxes = new List<Mailbox>(MailboxCreateNumber);
     _unboundedMailboxType = new UnboundedMailbox();
     _boundedMailboxType = new BoundedMailbox(_actorSystem.Settings, MailboxConfig);
     _unboundedDequeBasedMailboxType = new UnboundedDequeBasedMailbox(_actorSystem.Settings, MailboxConfig);
     _boundedDequeBasedMailboxType = new BoundedDequeBasedMailbox(_actorSystem.Settings, MailboxConfig);
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:9,代码来源:MailboxMemoryFootprintSpec.cs

示例5: SetUp

        public void SetUp(BenchmarkContext context)
        {
            _scheduledOpsCounter = context.GetCounter(ScheduledOps);
            _jobsScheduled = context.GetCounter(ScheduledJobs);
            _actorSystem = ActorSystem.Create("SchedulerPerformanceSpecs");
            _cancelSignal = new Cancelable(_actorSystem.Scheduler);
            _counterIncrement = () => _scheduledOpsCounter.Increment();

            _eventLoop = () =>
            {
                while (!_cancelSignal.IsCancellationRequested)
                {
                    for (var i = 0; i < SchedulePerBatch; i++)
                    {
                        _actorSystem.Scheduler.Advanced.ScheduleRepeatedly(0, 10, _counterIncrement, _cancelSignal);
                        _jobsScheduled.Increment();
                    }
                    Thread.Sleep(40); // wait a bit, then keep going
                }
            };
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:21,代码来源:DefaultSchedulerPerformanceTests.cs

示例6: PerfSetUp

 public void PerfSetUp(BenchmarkContext context)
 {
     benchmarkCounter = context.GetCounter(MessagesReceivedCounter);
     StartServer((data, channel) =>
     {
         benchmarkCounter.Increment();
         var serverReceived = ServerReceived.GetAndIncrement();
         if (serverReceived >= MessageCount - 1)
             _resentEvent.Set();
     });
     StartClient();
     message = new byte[MessageLength];
 }
开发者ID:helios-io,项目名称:helios,代码行数:13,代码来源:SocketThroughputSpec.cs

示例7: SetUp

        public void SetUp(BenchmarkContext context)
        {
            ServerGroup = new MultithreadEventLoopGroup(1);
            WorkerGroup = new MultithreadEventLoopGroup();


            var iso = Encoding.GetEncoding("ISO-8859-1");
            message = Unpooled.Buffer().WriteInt(3).WriteBytes(iso.GetBytes("ABC")).ToArray();


            _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName);
            _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName);
            var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter);
            _signal = new ManualResetEventSlimReadFinishedSignal(ResetEvent);

            var sb = new ServerBootstrap().Group(ServerGroup, WorkerGroup).Channel<TcpServerSocketChannel>()
                .ChildOption(ChannelOption.TcpNodelay, true)
                .ChildHandler(
                    new ActionChannelInitializer<TcpSocketChannel>(
                        channel =>
                        {
                            channel.Pipeline.AddLast(GetEncoder())
                                .AddLast(GetDecoder())
                                .AddLast(counterHandler)
                                .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter))
                                .AddLast(new ReadFinishedHandler(_signal, WriteCount));
                        }));

            // start server
            _serverChannel = sb.BindAsync(TEST_ADDRESS).Result;

            // connect to server
            var address = (IPEndPoint) _serverChannel.LocalAddress;
            ClientSocket = new System.Net.Sockets.Socket(AddressFamily.InterNetworkV6, SocketType.Stream,
                ProtocolType.Tcp);
            ClientSocket.Connect(address.Address, address.Port);

            Stream = new NetworkStream(ClientSocket, true);
        }
开发者ID:helios-io,项目名称:helios,代码行数:39,代码来源:TcpChannelInboundOnlyPerfSpec.cs

示例8: Setup

        public void Setup(BenchmarkContext context)
        {
            MsgReceived = context.GetCounter("MsgReceived");
            System = ActorSystem.Create("PerfSys");
            Action<IActorDsl> actor = d => d.ReceiveAny((o, c) =>
            {
                MsgReceived.Increment();
            });
            TestActor = System.ActorOf(Props.Create(() => new Act(actor)), "testactor");
            var id = TestActor.Ask<ActorIdentity>(new Identify(null), TimeSpan.FromSeconds(3)).Result;

            Mailbox = new Mailbox(new UnboundedMessageQueue());
            Mailbox.SetActor(TestActor.AsInstanceOf<RepointableActorRef>().Underlying.AsInstanceOf<ActorCell>());
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:14,代码来源:MailboxBenchmarks.cs

示例9: Setup

        public void Setup(BenchmarkContext context)
        {
            MsgReceived = context.GetCounter("MsgReceived");
            System = ActorSystem.Create("PerfSys", Config);
            Action<IActorDsl> actor = d => d.ReceiveAny((o, c) =>
            {
                MsgReceived.Increment();
            });
            TestActor = System.ActorOf(Props.Create(() => new Act(actor)).WithDispatcher("calling-thread-dispatcher"), "testactor");

            // force initialization of the actor
            TestActor.Tell("warmup");
            MsgReceived.Decrement();
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:14,代码来源:MessageDispatchAndReceiveBenchmark.cs

示例10: SetUp

        public void SetUp(BenchmarkContext context)
        {
            ClientGroup = new MultithreadEventLoopGroup(1);
            ServerGroup = new MultithreadEventLoopGroup(1);
            WorkerGroup = new MultithreadEventLoopGroup();


            var iso = Encoding.GetEncoding("ISO-8859-1");
            message = iso.GetBytes("ABC");

            // pre-allocate all messages
            foreach (var m in Enumerable.Range(0, WriteCount))
            {
                messages[m] = Unpooled.WrappedBuffer(message);
            }

            _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName);
            _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName);
            var counterHandler = new CounterHandlerInbound(_inboundThroughputCounter);
            _signal = new ManualResetEventSlimReadFinishedSignal(ResetEvent);

            var sb = new ServerBootstrap().Group(ServerGroup, WorkerGroup).Channel<TcpServerSocketChannel>()
                .ChildOption(ChannelOption.TcpNodelay, true)
                .ChildHandler(
                    new ActionChannelInitializer<TcpSocketChannel>(
                        channel =>
                        {
                            channel.Pipeline.AddLast(GetEncoder())
                                .AddLast(GetDecoder())
                                .AddLast(counterHandler)
                                .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter))
                                .AddLast(new ReadFinishedHandler(_signal, WriteCount));
                        }));

            var cb = new ClientBootstrap().Group(ClientGroup)
                .Option(ChannelOption.TcpNodelay, true)
                .Channel<TcpSocketChannel>().Handler(new ActionChannelInitializer<TcpSocketChannel>(
                    channel =>
                    {
                        channel.Pipeline.AddLast(GetEncoder()).AddLast(GetDecoder()).AddLast(counterHandler)
                            .AddLast(new CounterHandlerOutbound(_outboundThroughputCounter));
                    }));

            // start server
            _serverChannel = sb.BindAsync(TEST_ADDRESS).Result;

            // connect to server
            _clientChannel = cb.ConnectAsync(_serverChannel.LocalAddress).Result;
            //_clientChannel.Configuration.AutoRead = false;
        }
开发者ID:helios-io,项目名称:helios,代码行数:50,代码来源:TcpChannelPerfSpecs.cs

示例11: Setup

 public void Setup(BenchmarkContext context)
 {
     Sys = ActorSystem.Create("Sys");
     Prereqs = new DefaultDispatcherPrerequisites(Sys.EventStream, Sys.Scheduler, Sys.Settings, Sys.Mailboxes);
     _configurator = Configurator();
     _dispatcher = _configurator.Dispatcher();
     _dispatcherCounter = context.GetCounter(DispatcherCounterName);
     ScheduledWork = () =>
     {
         _dispatcherCounter.Increment();
         if (Interlocked.Increment(ref _messagesSeen) == ScheduleCount)
         {
             EventBlock.Set();
         }
     };
     Warmup(_dispatcher);
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:17,代码来源:DispatcherThroughputSpecBase.cs

示例12: Setup

        public void Setup(BenchmarkContext context)
        {
            MsgReceived = context.GetCounter("MsgReceived");
            System = ActorSystem.Create("PerfSys", Config);
            int count = 0;
            Action<IActorDsl> actor = d => d.ReceiveAny((o, c) =>
            {
                MsgReceived.Increment();
                count++;
                if(count == ExpectedMessages)
                    ResetEvent.Set();
            });
            TestActor = System.ActorOf(Props.Create(() => new Act(actor)).WithDispatcher("calling-thread-dispatcher"), "testactor");

            SpinWait.SpinUntil(() => TestActor.AsInstanceOf<RepointableActorRef>().IsStarted);

            // force initialization of the actor
            for(var i = 0; i < ExpectedMessages-1;i++)
                TestActor.AsInstanceOf<RepointableActorRef>().Underlying.AsInstanceOf<ActorCell>().Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.Nobody)); // queue all of the messages into the actor
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:20,代码来源:ReceiveOnlyBenchmark.cs

示例13: SetUp

        public void SetUp(BenchmarkContext context)
        {
            this.ServerGroup = new MultithreadEventLoopGroup(1);
            this.WorkerGroup = new MultithreadEventLoopGroup();

            Encoding iso = Encoding.GetEncoding("ISO-8859-1");
            this.message = Unpooled.Buffer().WriteInt(3).WriteBytes(iso.GetBytes("ABC")).ToArray();

            this.inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName);
            var counterHandler = new CounterHandlerInbound(this.inboundThroughputCounter);
            this.signal = new ManualResetEventSlimReadFinishedSignal(this.ResetEvent);

            // using default settings
            this.serverBufferAllocator = new PooledByteBufferAllocator();

            ServerBootstrap sb = new ServerBootstrap()
                .Group(this.ServerGroup, this.WorkerGroup)
                .Channel<TcpServerSocketChannel>()
                .ChildOption(ChannelOption.Allocator, this.serverBufferAllocator)
                .ChildHandler(new ActionChannelInitializer<TcpSocketChannel>(channel =>
                {
                    channel.Pipeline
                        .AddLast(this.GetEncoder())
                        .AddLast(this.GetDecoder())
                        .AddLast(counterHandler)
                        .AddLast(new ReadFinishedHandler(this.signal, WriteCount));
                }));

            // start server
            this.serverChannel = sb.BindAsync(TEST_ADDRESS).Result;

            // connect to server
            var address = (IPEndPoint)this.serverChannel.LocalAddress;
            this.ClientSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
            this.ClientSocket.Connect(address.Address, address.Port);

            this.Stream = new NetworkStream(this.ClientSocket, true);
        }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:38,代码来源:TcpSocketChannelInboundOnlyPerfSpec.cs

示例14: Setup

 public void Setup(BenchmarkContext context)
 {
     this.counter = context.GetCounter(CounterName);
 }
开发者ID:paiden,项目名称:Nett,代码行数:4,代码来源:WriteTomlTablePerfTestsV1.cs

示例15: Setup

 public void Setup(BenchmarkContext context)
 {
     _parseThroughput = context.GetCounter(ParseThroughputCounterName);
 }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:4,代码来源:AddressSpec.cs


注:本文中的NBench.BenchmarkContext.GetCounter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。