public void NewActorSelectionOnNewActorThroughput(BenchmarkContext context) { var actorRef = System.ActorOf(_oneMessageBenchmarkProps); // create a new actor every time System.ActorSelection(actorRef.Path).Tell("foo"); // send that actor a message via selection _resetEvent.Wait(); _resetEvent.Reset(); }
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"; // 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; }
public void OneWayThroughputBenchmark(BenchmarkContext context) { for (var i = 0; i < MessageCount; i++) { Send(message); } _resentEvent.Wait(); }
public void UntypedActorMemoryFootprint(BenchmarkContext context) { for (var i = 0; i < ActorCreateNumber; i++) { _system.ActorOf(UntypedActorProps); _createActorThroughput.Increment(); } }
public void ReceiveActor_memory_footprint(BenchmarkContext context) { for (var i = 0; i < ActorCreateNumber; i++) { _system.ActorOf(ReceiveActorProps); _createActorThroughput.Increment(); } }
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 AddThroughput_IterationsMode(BenchmarkContext context) { for (var i = 0; i < AcceptableMinAddThroughput; i++) { dictionary.Add(i, i); addCounter.Increment(); } }
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 FiberThroughputSingleDelegate(BenchmarkContext context) { for (var i = 0; i < ExecutorOperations;) { _executor.Execute(Operation); ++i; } SpinWait.SpinUntil(() => eventCount.Current >= ExecutorOperations, TimeSpan.FromSeconds(3)); }
public void Setup(BenchmarkContext context) { _counter = context.GetCounter("TestCounter"); var fixture = new Fixture(); fixture.RepeatCount = 100; _list = fixture.Create<List<string>>(); _algorithm = new Algorithm1(); }
public void ConcurrentCircularBufferWithResizing(BenchmarkContext context) { for (var i = 0; i < ResizedItemCount;) { concurrentCircularBuffer.Add(i); _insertsCounter.Increment(); ++i; } }
public void Setup(BenchmarkContext context) { _actorSystem = ActorSystem.Create("MaterializationBenchmark", ConfigurationFactory.FromResource<AkkaSpec>("Akka.Streams.TestKit.Tests.reference.conf")); _actorSystem.Settings.InjectTopLevelFallback(ActorMaterializer.DefaultConfig()); _materializerSettings = ActorMaterializerSettings.Create(_actorSystem).WithDispatcher("akka.test.stream-dispatcher"); _materializer = _actorSystem.Materializer(_materializerSettings); }
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); }
public void Setup(BenchmarkContext context) { _actorSystem = ActorSystem.Create("MessageDispatcher" + Counter.GetAndIncrement(), RemoteHocon); _systemAddress = RARP.For(_actorSystem).Provider.DefaultAddress; _inboundMessageDispatcherCounter = context.GetCounter(MessageDispatcherThroughputCounterName); _message = SerializedMessage.CreateBuilder().SetSerializerId(0).SetMessage(ByteString.CopyFromUtf8("foo")).Build(); _dispatcher = new DefaultMessageDispatcher(_actorSystem, RARP.For(_actorSystem).Provider, _actorSystem.Log); _targetActorRef = new BenchmarkActorRef(_inboundMessageDispatcherCounter, RARP.For(_actorSystem).Provider); }
public void Benchmark(BenchmarkContext context) { for (var i = 0; i < MailboxMessageCount;) { _receiver.Tell(string.Empty); ++i; } _resetEvent.Wait(); //wait up to a second }
public void FiberThroughputDynamicDelegate(BenchmarkContext context) { for (var i = 0; i < FiberOperations;) { _fiber.Add(() => Operation()); ++i; } SpinWait.SpinUntil(() => eventCount.Current >= FiberOperations, TimeSpan.FromSeconds(3)); }
public void Schedule_throughput(BenchmarkContext context) { for (var i = 0L; i < ScheduleCount;) { _dispatcher.Schedule(ScheduledWork); ++i; } EventBlock.Wait(); }
public void MemoryFootprint(BenchmarkContext context) { var actorPaths = new Address[100000]; for (var i = 0; i < 100000;) { actorPaths[i] = new Address("akka", "foo", "localhost", 9091); ++i; _parseThroughput.Increment(); } }
public void ReusedActorSelectionOnPreExistingActorThroughput(BenchmarkContext context) { var actorSelection = System.ActorSelection(_receiverActorPath); for (var i = 0; i < NumberOfMessages;) { actorSelection.Tell("foo"); ++i; } _resetEvent.Wait(); }
public void Setup(BenchmarkContext context) { _actorSystem = ActorSystem.Create("FileSourcesBenchmark"); _materializer = _actorSystem.Materializer(); _file = CreateFile(); _fileChannelSource = FileIO.FromFile(_file, BufferSize); _fileInputStreamSource = StreamConverters.FromInputStream(() => File.OpenRead(_file.FullName), BufferSize); _ioSourceLinesIterator = Source.FromEnumerator(() => File.ReadLines(_file.FullName).Select(ByteString.FromString).GetEnumerator()); }
public void TearDown(BenchmarkContext context) { var shutdownTimeout = TimeSpan.FromSeconds(5); try { _sys?.Terminate().Wait(shutdownTimeout); } catch (Exception ex) { context.Trace.Error(ex, $"failed to shutdown actorsystem within {shutdownTimeout}"); } }
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]; }
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(); }
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>()); }
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) { _configurator = Configurator(); _dispatcher = _configurator.Dispatcher(); _dispatcherCounter = context.GetCounter(DispatcherCounterName); ScheduledWork = () => { _dispatcherCounter.Increment(); if (Interlocked.Increment(ref _messagesSeen) == ScheduleCount) { EventBlock.Set(); } }; Warmup(_dispatcher); }
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); }
public void MailboxBatchRunPerf(BenchmarkContext context) { Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.MessageQueue.Enqueue(TestActor, new Envelope("hit", ActorRefs.NoSender)); Mailbox.Run(); }
public void AssociationStress(BenchmarkContext context) { var registryKey = CreateRegistryKey(); using ( var system1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0, registryKey))) using ( var system2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0, registryKey))) { var echo = system1.ActorOf(ActorProps, "echo"); var system1Address = RARP.For(system1).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var remoteActor = system2.ActorSelection(system1EchoActorPath) .Ask<ActorIdentity>(new Identify(null), TimeSpan.FromSeconds(2)).Result.Subject; AssociationCounter.Increment(); } }
public void Setup(BenchmarkContext context) { _actorSystem = ActorSystem.Create("MergeManyBenchmark", ConfigurationFactory.FromResource<ScriptedTest>("Akka.Streams.TestKit.Tests.reference.conf")); _actorSystem.Settings.InjectTopLevelFallback(ActorMaterializer.DefaultConfig()); _materializerSettings = ActorMaterializerSettings.Create(_actorSystem).WithDispatcher("akka.test.stream-dispatcher"); _materializer = _actorSystem.Materializer(_materializerSettings); var takeSource = CreateSource(NumberOfElements); var singleSubSource = CreateSource(NumberOfElements); var singleSource = Source.Repeat(0).Take(1).MergeMany(1, _ => singleSubSource); var tenSubSources = CreateSource(NumberOfElements/10); var tenSources = Source.Repeat(0).Take(10).MergeMany(10, _ => tenSubSources); _takeGraph = ToSource(takeSource); _singleGraph = ToSource(singleSource); _tenGraph = ToSource(tenSources); }