Example #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);
     }
 }
Example #2
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);
            }
        }
Example #3
0
        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);
            }
        }
 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);
     }
 }