Beispiel #1
0
        [Test]//Do not worry about it if this test fails when running in ncrunch. It runs it much slower for some reason. Probably due to intrumenting the assembly. Just ignore it in ncrunch.
        public void A_hundred_thousand_events_large_aggregate_with_four_migrations_should_load_cached_in_less_than_150_milliseconds()
        {
            var eventMigrations = Seq.Create <IEventMigration>(
                Before <E6> .Insert <E2>(),
                Before <E7> .Insert <E3>(),
                Before <E8> .Insert <E4>(),
                Before <E9> .Insert <E5>()
                ).ToArray();

            using (var container = CreateContainerForEventStoreType(() => eventMigrations, EventStoreType))
            {
                var timeSource = container.Resolve <DummyTimeSource>();

                var history   = Seq.OfTypes <Ec1>().Concat(1.Through(100000).Select(index => typeof(E1))).ToArray();
                var aggregate = TestAggregate.FromEvents(timeSource, Guid.NewGuid(), history);
                container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Save(aggregate));

                //Warm up cache..
                container.ExecuteUnitOfWorkInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(aggregate.Id));

                TimeAsserter.Execute(
                    maxTotal: 150.Milliseconds().AdjustRuntimeForNCrunch(boost: 6),
                    description: "load aggregate in isolated scope",
                    action: () => container.ExecuteInIsolatedScope(() => container.Resolve <IEventStoreSession>().Get <TestAggregate>(aggregate.Id)));
            }
        }
        public void Calling_before_after_or_replace_1000_000_times_takes_less_than_60_milliseconds()
        {
            var before = Before <E3> .Insert <E2>().CreateSingleAggregateInstanceHandlingMigrator();

            var replace = Replace <E3> .With <E2>().CreateSingleAggregateInstanceHandlingMigrator();

            var after = After <E3> .Insert <E2>().CreateSingleAggregateInstanceHandlingMigrator();

            var @event        = new E2();
            var eventModifier = new EventModifier(@event, _ => { });

            var numberOfEventsToInspect = 1000000;
            var maxtime = TestEnvironmentPerformance.AdjustRuntime(60.Milliseconds(), boost: 12.0);

            TimeAsserter.Execute(
                maxTotal: maxtime,
                description: $"{nameof(before)}",
                iterations: numberOfEventsToInspect,
                action: () => before.MigrateEvent(@event, @eventModifier));
            TimeAsserter.Execute(
                maxTotal: maxtime,
                description: $"{nameof(replace)}",
                iterations: numberOfEventsToInspect,
                action: () => replace.MigrateEvent(@event, @eventModifier));
            TimeAsserter.Execute(
                maxTotal: maxtime,
                description: $"{nameof(after)}",
                iterations: numberOfEventsToInspect,
                action: () => after.MigrateEvent(@event, @eventModifier));
        }
        public void ShouldRun50TestsInOneMillisecond() //The Activator.CreateInstance stuff in the default check had me a bit worried. Seems I had no reason to be.
        {
            var one = 1;

            TimeAsserter.Execute(
                action: () => Contract.Argument(() => one).NotNullOrDefault(),
                iterations: 500,
                maxTotal: 10.Milliseconds());
        }
Beispiel #4
0
        public void ShouldRun50TestsIn1Millisecond() //The expression compilation stuff was worrying but this should be OK except for tight loops.
        {
            var notNullOrDefault = new object();

            TimeAsserter.Execute(
                action: () => Contract.Argument(() => notNullOrDefault).NotNullOrDefault(),
                iterations: 500,
                maxTotal: 10.Milliseconds()
                );
        }
        public void When_there_are_no_migrations_mutation_takes_less_than_a_millisecond()
        {
            var eventMigrations = Seq.Create <IEventMigration>().ToArray();

            TimeAsserter.Execute(
                maxAverage: 1.Milliseconds(),
                iterations: 10,
                description: "load aggregate in isolated scope",
                timeFormat: "ss\\.fff",
                action: () => { SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory(eventMigrations, _history); });
        }
        public void With_four_migrations_that_change_nothing_mutation_takes_less_than_10_milliseconds()
        {
            var eventMigrations = Seq.Create <IEventMigration>(
                Before <E3> .Insert <E1>(),
                Before <E5> .Insert <E1>(),
                Before <E7> .Insert <E1>(),
                Before <E9> .Insert <E1>()
                ).ToArray();

            var maxAverage = 10.Milliseconds().AdjustRuntimeForNCrunch(boost: 6);

            TimeAsserter.Execute(
                maxTotal: maxAverage,
                maxTries: 10,
                description: "load aggregate in isolated scope",
                timeFormat: "ss\\.fff",
                action: () => { SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory(eventMigrations, _history); });
        }
        public void With_four_migrations_mutation_that_all_actually_changes_things_migration_takes_less_than_15_milliseconds()
        {
            var eventMigrations = Seq.Create <IEventMigration>(
                Before <E2> .Insert <E3>(),
                Before <E4> .Insert <E5>(),
                Before <E6> .Insert <E7>(),
                Before <E8> .Insert <E9>()
                ).ToArray();

            var maxAverage = TestEnvironmentPerformance.AdjustRuntime(15.Milliseconds(), boost: 2);

            TimeAsserter.Execute(
                maxTotal: maxAverage,
                description: "load aggregate in isolated scope",
                maxTries: 10,
                timeFormat: "ss\\.fff",
                action: () => { SingleAggregateInstanceEventStreamMutator.MutateCompleteAggregateHistory(eventMigrations, _history); });
        }
        public void Aggregate_should_raise_100_000_events_in_less_than_180_milliseconds()
        {
            var history = Seq.OfTypes <Ec1>()
                          .Concat(1.Through(10000).Select(_ => typeof(E1)))
                          .Concat(1.Through(10000).Select(_ => typeof(E2)))
                          .Concat(1.Through(10000).Select(_ => typeof(E3)))
                          .Concat(1.Through(10000).Select(_ => typeof(E4)))
                          .Concat(1.Through(10000).Select(_ => typeof(E5)))
                          .Concat(1.Through(10000).Select(_ => typeof(E6)))
                          .Concat(1.Through(10000).Select(_ => typeof(E7)))
                          .Concat(1.Through(10000).Select(_ => typeof(E8)))
                          .Concat(1.Through(10000).Select(_ => typeof(E9)))
                          .Concat(1.Through(10000).Select(_ => typeof(Ef)))
                          .ToEvents();

            TimeAsserter.Execute(
                maxTotal: 180.Milliseconds().AdjustRuntimeForNCrunch(boost: 2),
                action: () => new TestAggregate2(history));
        }