public void Run() { var manager = new EventStoreManager(); //manager.CompressionStrategy = new NoCompressionStrategy(); using (var stream = new FileStream("0.event", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1)) { var file = new StreamEventFileStorage(stream); _writeStore = manager.AppendToStore(file); var consumerTask = Task.Factory.StartNew(EventConsumer, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler); _sw.Start(); var tasks = new Task[ParallelTasks]; Parallel.For(0, tasks.Length, i => { tasks[i] = PublishSampleEvents(RepetitionCount); }); Task.WaitAll(tasks); _bc.CompleteAdding(); consumerTask.Wait(); _sw.Stop(); Console.WriteLine("Write {0}ms events per second:{1:f0} total len:{2}", _sw.ElapsedMilliseconds, tasks.Length * RepetitionCount / _sw.Elapsed.TotalSeconds, stream.Length); _sw.Restart(); var allObserverCounter = new AllObserverCounter(); manager.OpenReadOnlyStore(file).ReadFromStartToEnd(allObserverCounter); _sw.Stop(); Console.WriteLine("Read {0}ms events per second:{1:f0} events:{2}", _sw.ElapsedMilliseconds, allObserverCounter.Count / _sw.Elapsed.TotalSeconds, allObserverCounter.Count); } }
public void Read() { var manager = new EventStoreManager(); manager.SetNewTypeNameMapper(new OverloadableTypeMapper(typeof(ClassWithChangedUINTtoULONG), "BTDBTest.EventStoreTest+Credit")); using (var file = new StreamEventFileStorage(new MemoryStream(Convert.FromBase64String(base64EventFile)))) { var appender = manager.AppendToStore(file); var observer = new StoringEventObserver(); appender.ReadFromStartToEnd(observer); Assert.Equal(observer.Events.Count, 1); Assert.Equal(observer.Events[0].Length, 1); var e = observer.Events[0][0] as Ev1; Assert.Equal(e.Credit.A, 1u); Assert.Equal(e.Credit.B, 2u); } }
public void Run() { _ring = new RingBuffer <ValueEvent>(() => new ValueEvent(), new MultiThreadedClaimStrategy(2048), new YieldingWaitStrategy()); _sequenceBarrier = _ring.NewBarrier(); _sequence = new Sequence(Sequencer.InitialCursorValue); _ring.SetGatingSequences(_sequence); var manager = new EventStoreManager(); //manager.CompressionStrategy = new NoCompressionStrategy(); using (var stream = new FileStream("0.event", FileMode.Create, FileAccess.ReadWrite, FileShare.None, 1)) { var file = new StreamEventFileStorage(stream); _writeStore = manager.AppendToStore(file); var consumerTask = Task.Factory.StartNew(EventConsumer, TaskCreationOptions.LongRunning | TaskCreationOptions.HideScheduler); _sw.Start(); var tasks = new Task[ParallelTasks]; Parallel.For(0, tasks.Length, i => { tasks[i] = PublishSampleEvents(RepetitionCount); }); Task.WaitAll(tasks); _sequenceBarrier.Alert(); consumerTask.Wait(); _sw.Stop(); Console.WriteLine("Write {0}ms events per second:{1:f0} total len:{2}", _sw.ElapsedMilliseconds, tasks.Length * RepetitionCount / _sw.Elapsed.TotalSeconds, stream.Length); _sw.Restart(); var allObserverCounter = new AllObserverCounter(); manager.OpenReadOnlyStore(file).ReadFromStartToEnd(allObserverCounter); _sw.Stop(); Console.WriteLine("Read {0}ms events per second:{1:f0} events:{2}", _sw.ElapsedMilliseconds, allObserverCounter.Count / _sw.Elapsed.TotalSeconds, allObserverCounter.Count); } }