Пример #1
0
 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 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);
     }
 }
Пример #3
0
 static object PassThroughEventStorage(object @event, ITypeNameMapper mapper)
 {
     var manager = new EventStoreManager();
     var storage = new MemoryEventFileStorage();
     var appender = manager.AppendToStore(storage);
     var events = new[]
         {
             @event
         };
     appender.Store(null, events);
     manager = new EventStoreManager();
     manager.SetNewTypeNameMapper(mapper);
     var eventObserver = new EventStoreTest.StoringEventObserver();
     manager.OpenReadOnlyStore(storage).ReadFromStartToEnd(eventObserver);
     return eventObserver.Events[0][0];
 }