當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。