Increment() public method

Increment the value of the counter by 1
public Increment ( ) : void
return void
コード例 #1
0
 public BenchmarkActor(Counter counter, long maxExpectedMessages, ManualResetEventSlim resetEvent)
 {
     _counter = counter;
     _maxExpectedMessages = maxExpectedMessages;
     _resetEvent = resetEvent;
     ReceiveAny(o =>
     {
         _counter.Increment();
         if (++_currentMessages == _maxExpectedMessages)
             _resetEvent.Set();
     });
 }
コード例 #2
0
 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];
 }
コード例 #3
0
        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();
        }
コード例 #4
0
        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>());
        }
コード例 #5
0
 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);
 }
コード例 #6
0
 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);
 }
コード例 #7
0
        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
        }
コード例 #8
0
        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
                }
            };
        }