Exemplo n.º 1
0
        public async Task ReceiveMessage_AvgTimeIsBelow1Ms()
        {
            i1 = new IpcInterface();
            i2 = new IpcInterface(i1.PartnerPort, i1.Port);
            var dummyClass = new DummyClass();
            var stopwatch  = new Stopwatch();

            var spinLock = true;

            i1.On <DummyClass>(dc =>
            {
                stopwatch.Stop();
                spinLock = false;
            });

            for (var i = 0; i < Iterations; i++)
            {
                await i2.SendMessage(dummyClass);

                stopwatch.Start();
                while (spinLock)
                {
                    await Task.Delay(1);
                }
                spinLock = true;
            }

            var averageMs = stopwatch.ElapsedMilliseconds / Iterations;

            Assert.IsTrue(averageMs <= 1, "Expected <=1ms, got {0}ms", averageMs);
        }
Exemplo n.º 2
0
        public static async Task MainAsync(string[] args)
        {
            var i2 = new IpcInterface(int.Parse(args[0]), int.Parse(args[1]));
            await i2.SendMessage(new DummyClass());

            await Task.Delay(-1);
        }
Exemplo n.º 3
0
        private async Task SpinlockForMessage()
        {
            var spinLock = true;

            i1.On <DummyClass>(dummyClass => { spinLock = false; });
            await i2.SendMessage(new DummyClass());

            while (spinLock)
            {
                await Task.Delay(SpinlockWait);
            }
        }
Exemplo n.º 4
0
        public async Task On_FiresOnCorrectTypeOnly()
        {
            i1 = new IpcInterface();
            i2 = new IpcInterface(i1.PartnerPort, i1.Port);

            var spinLock = true;

            i1.On <DummyClass>(dummyClass => { spinLock = false; });
            i1.On <DummierClass>(dummierClass => {});
            await i2.SendMessage(new DummierClass());

            await Task.Delay(SpinlockWait * 5000);

            Assert.IsTrue(spinLock);
        }
Exemplo n.º 5
0
        public async Task SendMessage_AvgTimeIsBelow1Ms()
        {
            i1 = new IpcInterface();
            i2 = new IpcInterface(i1.PartnerPort, i1.Port);
            var stopwatch = new Stopwatch();

            i1.On <DummyClass>(dummyClass => {});

            for (var i = 0; i < Iterations; i++)
            {
                stopwatch.Start();
                await i2.SendMessage(new DummyClass());

                stopwatch.Stop();
            }

            var averageMs = stopwatch.ElapsedMilliseconds / Iterations;

            Assert.IsTrue(averageMs <= 1, "Expected <=1ms, got {0}ms", averageMs);
        }