示例#1
0
        public SampleApp(IPersistence store, string name, bool useSnapshots, bool quiet, bool fast)
        {
            _quiet        = quiet;
            _name         = name;
            _rooms        = 32;
            _storeProfile = new ProfileDecorator(store);

            _streams          = new StreamsFactory(_storeProfile);
            _aggregateFactory = new DefaultAggregateFactory();

            var network = fast
                ? (INetworkSimulator) new NoNetworkLatencySimulator()
                : (INetworkSimulator) new ReliableNetworkSimulator(10, 50);

            _appProjections = new AppProjections(network, quiet);

            _poller = new PollingClient(_storeProfile, 0, _appProjections, this._loggerFactory);

            if (useSnapshots)
            {
                _cloneProfiler = new TaskProfilingInfo("Cloning state");

                var inMemoryPersistence = new InMemoryPersistence(new InMemoryPersistenceOptions
                {
                    CloneFunc = CloneSnapshot
                });
                _snapshotProfile = new ProfileDecorator(inMemoryPersistence);
                _snapshots       = new DefaultSnapshotStore(_snapshotProfile);
            }

            _unboundedOptions = new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = DataflowBlockOptions.Unbounded,
                BoundedCapacity        = DataflowBlockOptions.Unbounded,
                EnsureOrdered          = false,
                MaxMessagesPerTask     = DataflowBlockOptions.Unbounded
            };

            _boundedOptions = new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount * 8,
                BoundedCapacity        = 500,
                EnsureOrdered          = true
            };


            if (store is MongoPersistence)
            {
                _unboundedOptions.MaxDegreeOfParallelism = Environment.ProcessorCount * 4;
                _unboundedOptions.BoundedCapacity        = 2000;
            }
        }
示例#2
0
        public async Task should_count_wait_time()
        {
            var pi = new TaskProfilingInfo("test");
            var sw = new Stopwatch();

            sw.Start();
            await pi.CaptureAsync(() => Wait(300)).ConfigureAwait(false);

            sw.Stop();

            Assert.True(sw.ElapsedMilliseconds >= 300, "sw.ElapsedMilliseconds >= 300");
            Assert.True(pi.Elapsed.TotalMilliseconds >= 300, "pi.Elapsed.Milliseconds >= 300");
        }
示例#3
0
        public async Task should_await_inner_task()
        {
            var pi = new TaskProfilingInfo("test");
            var sw = new Stopwatch();

            sw.Start();
            await pi.CaptureAsync(() => Wait(300)).ConfigureAwait(false);

            sw.Stop();

            // 280ms isteda of 300ms to avoid timer precision issues on build servers
            Assert.True(sw.ElapsedMilliseconds >= 280, $"sw.ElapsedMilliseconds >= 280. Was {sw.ElapsedMilliseconds}");
            Assert.True(pi.Elapsed.TotalMilliseconds >= 280, $"pi.Elapsed.Milliseconds >= 280. Was {pi.Elapsed.TotalMilliseconds}");
        }