public void Setup(BenchmarkContext context) { ThreadLocalRandom.Current.NextBytes(_bytes); _clients = new ConcurrentBag <IActorRef>(); _clientConnectedCounter = context.GetCounter(ClientConnectCounterName); _inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); _outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); _errorCounter = context.GetCounter(ErrorCounterName); var config = ConfigurationFactory.ParseString(@" akka { loglevel=INFO io.tcp.direct-buffer-pool { buffer-size = 64 buffers-per-segment = 1000 buffer-pool-limit = 10000 } }"); _system = ActorSystem.Create("TcpHorizontalScaleSpec", config); _listener = _system.ActorOf(Props.Create(() => new TestListener(TestEndPoint, _clientConnectedCounter, _inboundThroughputCounter, _errorCounter)), "listener"); var client = _system.ActorOf(Props.Create(() => new TestClient(TestEndPoint, _outboundThroughputCounter, _errorCounter, _bytes))); _clients.Add(client); }
public override void Setup(BenchmarkContext context) { base.Setup(context); _snapshotLoadCounter = context.GetCounter(SnapshotLoadCounterName); _recoveryCounter = context.GetCounter(RecoveryCounterName); StoreSnapshotForEachActor(); TerminateAllActors(); }
public void SetUp(BenchmarkContext context) { TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine(args.Exception); this.ClientGroup = new MultithreadEventLoopGroup(1); this.ServerGroup = new MultithreadEventLoopGroup(1); this.WorkerGroup = new MultithreadEventLoopGroup(); this.message = Encoding.UTF8.GetBytes("ABC"); this.inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); this.outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(this.inboundThroughputCounter); this.signal = new ManualResetEventSlimReadFinishedSignal(this.ResetEvent); // reserve up to 10mb of 16kb buffers on both client and server; we're only sending about 700k worth of messages this.serverBufferAllocator = new PooledByteBufferAllocator(); this.clientBufferAllocator = new PooledByteBufferAllocator(); Assembly assembly = typeof(TcpChannelPerfSpecs).Assembly; var tlsCertificate = TestResourceHelper.GetTestCertificate(); string targetHost = tlsCertificate.GetNameInfo(X509NameType.DnsName, false); ServerBootstrap sb = new ServerBootstrap() .Group(this.ServerGroup, this.WorkerGroup) .Channel <TcpServerSocketChannel>() .ChildOption(ChannelOption.Allocator, this.serverBufferAllocator) .ChildHandler(new ActionChannelInitializer <TcpSocketChannel>(channel => { channel.Pipeline //.AddLast(TlsHandler.Server(tlsCertificate)) .AddLast(this.GetEncoder()) .AddLast(this.GetDecoder()) .AddLast(counterHandler) .AddLast(new ReadFinishedHandler(this.signal, WriteCount)); })); Bootstrap cb = new Bootstrap() .Group(this.ClientGroup) .Channel <TcpSocketChannel>() .Option(ChannelOption.Allocator, this.clientBufferAllocator) .Handler(new ActionChannelInitializer <TcpSocketChannel>( channel => { channel.Pipeline //.AddLast(TlsHandler.Client(targetHost, null, (sender, certificate, chain, errors) => true)) .AddLast(this.GetEncoder()) .AddLast(this.GetDecoder()) .AddLast(new CounterHandlerOutbound(this.outboundThroughputCounter)); })); // start server this.serverChannel = sb.BindAsync(TEST_ADDRESS).Result; // connect to server this.clientChannel = cb.ConnectAsync(this.serverChannel.LocalAddress).Result; }
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); }
public void SetUp(BenchmarkContext context) { TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine(args.Exception); var dispatcher = new DispatcherEventLoop(); this.serverGroup = new MultithreadEventLoopGroup(_ => dispatcher, 1); this.workerGroup = new WorkerEventLoopGroup(dispatcher); this.clientGroup = new MultithreadEventLoopGroup(_ => new EventLoop(), 1); this.message = Encoding.UTF8.GetBytes("ABC"); this.inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); this.outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var counterHandler = new CounterHandlerInbound(this.inboundThroughputCounter); this.signal = new ManualResetEventSlimReadFinishedSignal(this.resetEvent); // reserve up to 10mb of 16kb buffers on both client and server; we're only sending about 700k worth of messages this.serverBufferAllocator = new PooledByteBufferAllocator(); this.clientBufferAllocator = new PooledByteBufferAllocator(); ServerBootstrap sb = new ServerBootstrap() .Group(this.serverGroup, this.workerGroup) .Channel <TcpServerChannel>() .ChildOption(ChannelOption.Allocator, this.serverBufferAllocator) .ChildHandler(new ActionChannelInitializer <TcpChannel>(channel => { channel.Pipeline .AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(counterHandler) .AddLast(new ReadFinishedHandler(this.signal, WriteCount)); })); Bootstrap cb = new Bootstrap() .Group(this.clientGroup) .Channel <TcpChannel>() .Option(ChannelOption.Allocator, this.clientBufferAllocator) .Handler(new ActionChannelInitializer <TcpChannel>( channel => { channel.Pipeline .AddLast(GetEncoder()) .AddLast(GetDecoder()) .AddLast(new CounterHandlerOutbound(this.outboundThroughputCounter)); })); // start server this.serverChannel = sb.BindAsync(TestAddress).Result; // connect to server this.clientChannel = cb.ConnectAsync(this.serverChannel.LocalAddress).Result; }
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; }
public void Setup(BenchmarkContext context) { _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName); System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _echo = System1.ActorOf(Props.Create(() => new EchoActor()), "echo"); System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _receiver = System2.ActorOf( Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, _resetEvent)), "benchmark"); var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress; var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var system2RemoteActorPath = new RootActorPath(system2Address) / "user" / "benchmark"; try { // set the timeout high here to avoid timeouts // TL;DR; - on slow machines it can take longer than 2 seconds to form the association, do the handshake, and reply back // using the in-memory transport. _remoteReceiver = System1.ActorSelection(system2RemoteActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result; _remoteEcho = System2.ActorSelection(system1EchoActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result; } catch (Exception ex) { context.Trace.Error(ex, "error occurred during setup."); throw; // re-throw the error to blow up the benchmark } }
public void SetUp(BenchmarkContext context) { _counter = context.GetCounter(CounterName); if (ConfigurationManager.AppSettings["TestKey"] != "42") throw new InvalidOperationException("TestKey from AppSettings could not be loaded!"); }
public void Benchmark_FetchAssociate(BenchmarkContext context) { _assocFetchCounter = context.GetCounter("AssociateFetchCounter"); var postResponse = _assocController.GetAssociates(); _assocFetchCounter.Increment(); }
public void Setup(BenchmarkContext context) { _blockchainService = GetRequiredService <IBlockchainService>(); _blockExecutingService = GetRequiredService <IBlockExecutingService>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _counter = context.GetCounter("TestCounter"); AsyncHelper.RunSync(async() => { var chain = await _blockchainService.GetChainAsync(); _block = new Block { Header = new BlockHeader { ChainId = chain.Id, Height = chain.BestChainHeight + 1, PreviousBlockHash = chain.BestChainHash, Time = Timestamp.FromDateTime(DateTime.UtcNow) }, Body = new BlockBody() }; _transactions = await _osTestHelper.GenerateTransferTransactions(1000); }); }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("TestCounter"); _controller = new ApplicationController(); TaskId = new Application().GetTasks().FirstOrDefault().Task_ID; UserId = new Application().GetUsers().FirstOrDefault().User_ID; }
public void Benchmark_FetchSkill(BenchmarkContext context) { _skillFetchCounter = context.GetCounter("SkillFetchCounter"); var postResponse = _skillController.GetSkills(); _skillFetchCounter.Increment(); }
public override void Setup(BenchmarkContext context) { base.Setup(context); _recoveryCounter = context.GetCounter(RecoveryCounterName); StoreAllEvents(); Supervisor.Ask <AllTerminated>(new TerminateAll(), TimeSpan.FromSeconds(10)).GetAwaiter().GetResult(); }
public void Setup(BenchmarkContext context) { var resource = new ProjectManagementEntitiesFake(); this.service = new TaskService(resource); perfCounter = context.GetCounter(counterName); }
public void Benchmark_FetchAssociateSkillReport(BenchmarkContext context) { _reportFetchCounter = context.GetCounter("ReportFetchCounter"); var postResponse = _assocController.GetSkillReport(); _reportFetchCounter.Increment(); }
public void Setup(BenchmarkContext context) { _system = ActorSystem.Create($"GetMailboxTypeSpec{Counter.GetAndIncrement()}"); _messageDispatcher = _system.Dispatchers.Lookup(EchoActor.Props.Dispatcher); _mailboxes = new Mailboxes(_system); _createActorThroughput = context.GetCounter(CreateThroughputCounter); }
public void Setup(BenchmarkContext context) { _blockchainService = GetRequiredService <IBlockchainService>(); _blockchainExecutingService = GetRequiredService <IBlockchainExecutingService>(); _chainManager = GetRequiredService <IChainManager>(); _osTestHelper = GetRequiredService <OSTestHelper>(); _counter = context.GetCounter("TestCounter"); AsyncHelper.RunSync(async() => { var chain = await _blockchainService.GetChainAsync(); var transactions = await _osTestHelper.GenerateTransferTransactions(1000); _block = _osTestHelper.GenerateBlock(chain.BestChainHash, chain.BestChainHeight, transactions); await _blockchainService.AddTransactionsAsync(transactions); await _blockchainService.AddBlockAsync(_block); chain = await _blockchainService.GetChainAsync(); await _blockchainService.AttachBlockToChainAsync(chain, _block); }); }
public void SetUp(BenchmarkContext context) { this.serverGroup = this.NewServerGroup(); this.workerGroup = this.NewWorkerGroup(this.serverGroup); this.clientGroup = this.NewClientGroup(); this.roundTripCounter = context.GetCounter(RoundTripCounterName); var address = new IPEndPoint(IPAddress.IPv6Loopback, 0); // Start server ServerBootstrap sb = new ServerBootstrap() .Group(this.serverGroup, this.workerGroup) .Channel <TServer>() .ChildHandler(new ActionChannelInitializer <TClient>(channel => { channel.Pipeline.AddLast(new EchoServerHandler()); })); IChannel server = sb.BindAsync(address).Result; var endPoint = (IPEndPoint)server.LocalAddress; // Connect to server this.clientHandler = new EchoClientHandler(this.roundTripCounter, TimeSpan.FromMilliseconds(Duration)); Bootstrap cb = new Bootstrap() .Group(this.clientGroup) .Channel <TClient>() .Handler(new ActionChannelInitializer <TClient>(channel => { channel.Pipeline.AddLast(this.clientHandler); })); this.client = cb.ConnectAsync(endPoint).Result; }
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 } }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("TestCounter"); _hash = Hash.FromString("FromStringFromStringFromStringFromString"); _hashBytes = _hash.Value.ToByteArray(); _hashBase64 = _hash.Value.ToBase64(); }
public void Setup(BenchmarkContext context) { inboundThroughputCounter = context.GetCounter(InboundThroughputCounterName); outboundThroughputCounter = context.GetCounter(OutboundThroughputCounterName); var random = new Random(); message = new byte[50]; random.NextBytes(message); system = ActorSystem.Create("TcpSingleConnectionSpec"); system.ActorOf(Props.Create(() => new TestListener(TestEndpoint, inboundThroughputCounter, resetEvent))); var completion = new TaskCompletionSource <int>(); client = system.ActorOf(Props.Create(() => new TestClient(TestEndpoint, outboundThroughputCounter, resetEvent, completion))); completion.Task.Wait(Timeout); }
#pragma warning disable xUnit1013 // It is nbench test public void Setup(BenchmarkContext context) #pragma warning restore xUnit1013 // Public method should be marked as test { _counter = context.GetCounter(TotalCommandsExecutedCounter); _commndsToExecute = CreateCommandPlan(100, 1000).ToArray(); _fakeEventStore = new FakeEventStore(); }
public void Setup(BenchmarkContext context) { expectedParentTasks = DataInitializer.GetAllParentTasks(); expectedTasks = DataInitializer.GetAllTasks(); mockRepository = new Mock <IParentTaskRepository>(); _counter = context.GetCounter("TestCounter"); }
public virtual void Setup(BenchmarkContext context) { _counter = context.GetCounter(TotalCommandsExecutedCounter); var aggregateId = Guid.NewGuid().ToString(); _commands = CreateAggregatePlan(100, aggregateId).ToArray(); _actorSystem = ActorSystem.Create("test", _actorSystemConfig); _actorSystem.InitLocalTransportExtension(); _actorSystem.InitDomainEventsSerialization(new EventsAdaptersCatalog()); var log = new XUnitAutoTestLoggerConfiguration(_testOutputHelper, LogEventLevel.Warning, GetType().Name).CreateLogger(); _actorSystem.AttachSerilogLogging(log); var dummy = _actorSystem.ActorOf <CustomHandlersActorDummy>(); _aggregateActor = _actorSystem.ActorOf(Props.Create( () => new AggregateActor <Balloon>(new BalloonCommandHandler(), new EachMessageSnapshotsPersistencePolicy(), AggregateFactory.Default, AggregateFactory.Default, dummy)), EntityActorName.New <Balloon>(aggregateId).ToString()); }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("TestCounter"); controller = new ProjectManagerController(); TaskId = new BusinessLayer.ProjectManagerCore().GetTasks().FirstOrDefault().Task_ID; UserId = new BusinessLayer.ProjectManagerCore().GetUsers().FirstOrDefault().User_ID; }
public void Setup(BenchmarkContext context) { _opCounter = context.GetCounter("CatCounter"); _catRepo = new CategoryRepository(); _catProvider = new CategoryProvider(_catRepo); _catToAdd = new List <string>(); }
public void Setup(BenchmarkContext context) { _mailboxThroughput = context.GetCounter(MailboxCounterName); System = ActorSystem.Create($"{GetType().Name}{Counter.GetAndIncrement()}"); _targetActor = new CounterRef(_mailboxThroughput); System.EventStream.Subscribe(_targetActor, typeof(string)); }
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)); }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter(TransformCounterName); _compositeTestAgent = new CompositeTestAgent(); _agent = _compositeTestAgent.GetAgent(); CreateTransactionAndSegments(); }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("ProjectCounter"); randomUsers = SetupUsers(); randomProjects = SetupProjects(); randomParents = SetupParent(); randomTasks = SetupTasks(); key = 0; }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("TestCounter"); _dbContext = this.GetService <DbContext>(); _memoryDatabase = _dbContext.Database; _memoryDatabase.SetAsync("hello", _testBytes); }
public void Setup(BenchmarkContext context) { _counter1 = context.GetCounter("Counter1"); _counter2 = context.GetCounter("Counter2"); }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("TestCounter"); }
public void BenchmarkSetupMethod(BenchmarkContext context) { _counter = context.GetCounter(CounterName.CounterName); }
public void SetUp(BenchmarkContext context) { _counter = context.GetCounter(CounterName); }