本文整理汇总了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);
}
示例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));
}
示例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();
}
示例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);
}
示例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
}
};
}
示例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];
}
示例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);
}
示例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>());
}
示例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();
}
示例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;
}
示例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);
}
示例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
}
示例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);
}
示例14: Setup
public void Setup(BenchmarkContext context)
{
this.counter = context.GetCounter(CounterName);
}
示例15: Setup
public void Setup(BenchmarkContext context)
{
_parseThroughput = context.GetCounter(ParseThroughputCounterName);
}