Ejemplo n.º 1
0
        public void MultiThreadedMemoizedInvocation_DifferentInvocations_Conjunction_2(
            //[Values(1, 2, 4, 10, 30, 60, 100, 200, 400, 800, 1000, 1200)] int numberOfConcurrentWorkerThreads
            [Values(1, 20)] int numberOfConcurrentWorkerThreads
            //,[Values(2)] int iterations
            )
        {
            try
            {
                //int NUMBER_OF_ITERATIONS = iterations;

                Interlocked.Exchange(ref reallySlowNetworkInvocation1a_INVOCATION_COUNTER, 0);
                //Interlocked.Exchange(ref reallySlowNetworkInvocation1d_INVOCATION_COUNTER, 0);

                TwoPhaseExecutionContext twoPhaseExecutionContext1 =
                    this.reallySlowNetworkInvocation1a.CreateExecutionContext(threads: numberOfConcurrentWorkerThreads,
                                                                              iterations: NUMBER_OF_ITERATIONS,
                                                                              memoize: true,
                                                                              instrumentation: false);

                TwoPhaseExecutionContext twoPhaseExecutionContext2 =
                    this.reallySlowNetworkInvocation1d.CreateExecutionContext(threads: 1,
                                                                              iterations: 100,                // N/A as it is merged into another TwoPhaseExecutionContext
                                                                              concurrent: false,              // Not implemented / N/A only 'concurrent: true is supported so far
                                                                              memoize: false,
                                                                                                              //memoizerClearing: false,
                                                                              functionLatency: default(long), // N/A as it is merged into another TwoPhaseExecutionContext
                                                                              instrumentation: false);

                /*TwoPhaseExecutionContext<string, long, string> mergedTwoPhaseExecutionContext = */
                twoPhaseExecutionContext1.And(twoPhaseExecutionContext2);
                //mergedTwoPhaseExecutionContext.Test();
                //twoPhaseExecutionContext1.Test();

                Assert.That(reallySlowNetworkInvocation1a_INVOCATION_COUNTER, Is.EqualTo(twoPhaseExecutionContext1.GetExpectedFunctionInvocationCountFor(this.reallySlowNetworkInvocation1a)));
                //Assert.That(reallySlowNetworkInvocation1a_INVOCATION_COUNTER, Is.EqualTo(twoPhaseExecutionContext1.ExpectedFunctionInvocationCount));
                ////Assert.That(reallySlowNetworkInvocation1a_INVOCATION_COUNTER, Is.EqualTo(mergedTwoPhaseExecutionContext.ExpectedFunctionInvocationCount));
                ////Assert.That(reallySlowNetworkInvocation1d_INVOCATION_COUNTER, Is.EqualTo(mergedTwoPhaseExecutionContext.ExpectedFunctionInvocationCount));
            }
            finally
            {
                // Clean-up: must remove memoized function from registry when doing several test method iterations
                this.reallySlowNetworkInvocation1a.UnMemoize();
                //this.reallySlowNetworkInvocation1d.UnMemoize();
            }
        }
Ejemplo n.º 2
0
        public void EqualTwoPhaseExecutionContextShouldReplaceOneAnotherWhenAddingTogetherContexts()
        {
            TwoPhaseExecutionContext twoPhaseExecutionContext = this.reallySlowNetworkInvocation1a.CreateExecutionContext(threads: 1, args: new dynamic[] { "yo", 13 }, memoize: true, instrumentation: true);

            twoPhaseExecutionContext.And(twoPhaseExecutionContext).Having(iterations: 1);
        }
Ejemplo n.º 3
0
        //[Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "An item with the same key has already been added.", MatchType = MessageMatch.Exact)]
        public void EqualTwoPhaseExecutionContextShouldNotBeAccepted()
        {
            TwoPhaseExecutionContext twoPhaseExecutionContext = this.reallySlowNetworkInvocation1a.CreateExecutionContext(threads: 1, args: new dynamic[] { "yo", 13 }, memoize: true, instrumentation: true);

            twoPhaseExecutionContext.And(twoPhaseExecutionContext).Having(iterations: 1);
        }