public void TestEventInheritanceRun() { var tcs = new TaskCompletionSource <bool>(); var runtime = new ProductionRuntime(); var a = runtime.CreateMachine(typeof(A), null, new A.Configure(tcs), null); runtime.SendEvent(a, new A.E3()); runtime.SendEvent(a, new E1()); runtime.SendEvent(a, new E2()); Assert.True(tcs.Task.Wait(2000), "Test timed out"); }
public void SendMessages() { var tcs = new TaskCompletionSource <bool>(); var runtime = new ProductionRuntime(); runtime.CreateMachine(typeof(Server), null, new Server.Configure(tcs, this.Clients, this.EventsPerClient), null); tcs.Task.Wait(); }
public void MeasureMessagingLatency() { var tcs = new TaskCompletionSource <bool>(); var runtime = new ProductionRuntime(); runtime.CreateMachine(typeof(Master), null, new SetupMasterEvent(tcs, this.NumMessages), null); tcs.Task.Wait(); }
public void MeasureLatencyExchangeEventViaReceive() { var tcs = new TaskCompletionSource <bool>(); var configuration = Configuration.Create(); var runtime = new ProductionRuntime(configuration); runtime.CreateMachine(typeof(M3), null, new SetupTcsEvent(tcs, this.NumMessages)); tcs.Task.Wait(); }
public void IterationSetup() { this.Runtime = new ProductionRuntime(); this.ExperimentAwaiter = new TaskCompletionSource <bool>(); var tcs = new TaskCompletionSource <bool>(); this.ProducerMachine = this.Runtime.CreateMachine(typeof(Producer), null, new SetupProducerEvent(tcs, this.ExperimentAwaiter, this.NumConsumers, this.NumMessages), null); tcs.Task.Wait(); }
public void MeasureMachineCreation() { var runtime = new ProductionRuntime(); var tcs = new TaskCompletionSource <bool>(); var e = new SetupEvent(tcs, NumMachines, DoHalt); for (int idx = 0; idx < NumMachines; idx++) { runtime.CreateMachine(typeof(M), null, e, null); } tcs.Task.Wait(); }
public void CreateMachines() { var runtime = new ProductionRuntime(); var tcs = new TaskCompletionSource <bool>(); Node.Configure evt = new Node.Configure(tcs, Size); for (int idx = 0; idx < Size; idx++) { runtime.CreateMachine(typeof(Node), null, evt, null); } tcs.Task.Wait(); }
public void MeasureThroughputMachineCreation() { var configuration = Configuration.Create(); var runtime = new ProductionRuntime(configuration); var tcs = new TaskCompletionSource <bool>(); var e = new SetupEvent(tcs, this.NumMachines, this.DoHalt); for (int idx = 0; idx < this.NumMachines; idx++) { runtime.CreateMachine(typeof(M), null, e); } tcs.Task.Wait(); }
public void RunWithLogger() { var configuration = PSharp.Configuration.Create().WithVerbosityEnabled(0); var runtime = new ProductionRuntime(configuration); ConcurrentQueue <MachineId> machines = new ConcurrentQueue <MachineId>(); Parallel.For(0, Clients, index => { machines.Enqueue(runtime.CreateMachine(typeof(SimpleMachine), new SetContextMessage(runtime))); }); foreach (var machine in machines) { runtime.SendEvent(machine, new Halt()); } }
public void IterationSetup() { var configuration = Configuration.Create(); this.Runtime = new ProductionRuntime(configuration); this.ExperimentAwaiter = new TaskCompletionSource <bool>(); var consumer = this.Runtime.CreateMachine(typeof(Consumer), null, new SetupConsumerEvent(this.ExperimentAwaiter, NumMessages)); var tasks = new Task[this.NumProducers]; this.ProducerMachines = new MachineId[this.NumProducers]; for (int i = 0; i < this.NumProducers; i++) { var tcs = new TaskCompletionSource <bool>(); this.ProducerMachines[i] = this.Runtime.CreateMachine(typeof(Producer), null, new SetupProducerEvent(tcs, consumer, NumMessages / this.NumProducers)); tasks[i] = tcs.Task; } Task.WaitAll(tasks); }
public void IterationCleanup() { this.Runtime = null; this.ProducerMachine = null; this.ExperimentAwaiter = null; }