コード例 #1
0
    static void Main()
    {
        for (int i = 0; i < Math.Max(1, Environment.ProcessorCount / 2); ++i)
        {
            // for (int i = 0; i < 4; ++i) {
            var t = new Thread(BackgroundNoise);
            t.IsBackground = true;
            t.Start();
        }

        int iterations = 0;

        for (TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 120 : 5)); timeout.HaveTimeLeft;)
        {
            var ad = AppDomain.CreateDomain("domain_" + iterations);
            ad.DoCallBack(new CrossAppDomainDelegate(AllocStuff));
            AppDomain.Unload(ad);

            Console.Write(".");
            if ((++iterations) % 20 == 0)
            {
                Console.WriteLine();
            }
        }
        Console.WriteLine($"\ndone {iterations} iterations");
    }
コード例 #2
0
	static void Main () {
		var testTimeout = new TestTimeout ();
		testTimeout.Start ();
		for (int i = 0; i < Math.Max (1, Environment.ProcessorCount / 2); ++i) {
		// for (int i = 0; i < 4; ++i) {
			var t = new Thread (BackgroundNoise);
			t.IsBackground = true;
			t.Start ();
		}
		
		const int TOTAL_ITERATIONS = 100;
		for (int i = 0; i < TOTAL_ITERATIONS; ++i) {
			var ad = AppDomain.CreateDomain ("domain_" + i);
			ad.DoCallBack (new CrossAppDomainDelegate (AllocStuff));
			AppDomain.Unload (ad);

			Console.Write (".");
			if (i > 0 && i % 20 == 0) Console.WriteLine ();

			if (!testTimeout.HaveTimeLeft ()) {
				var finishTime = DateTime.UtcNow;
				var ranFor = finishTime - testTimeout.StartTime;
				Console.WriteLine ("Will run out of time soon. ran for {0}, finished {1}/{2} iterations", ranFor, i+1, TOTAL_ITERATIONS);
			}
		}
		Console.WriteLine ("\ndone");
	}
コード例 #3
0
    static void Main(string[] args)
    {
        int iterations = 0;

        for (TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 120 : 5)); timeout.HaveTimeLeft;)
        {
            count = 0;

            List <Thread> threads             = new List <Thread>();
            List <System.Timers.Timer> timers = new List <System.Timers.Timer>();

            for (int i = 0; i < num_threads; i++)
            {
                Thread t3 = new Thread(delegate() {
                    UseMemory();
                });

                t3.Start();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed  += Timer_Elapsed;
                timer.AutoReset = false;
                timer.Interval  = 1000;
                timer.Start();
                timers.Add(timer);
            }

            for (int i = 0; i < 4000; i++)
            {
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed  += Timer_Elapsed;
                timer.AutoReset = false;
                timer.Interval  = 500;
                timer.Start();
                timers.Add(timer);
            }

            lock (count_lock)
            {
                while (count < num_threads)
                {
                    Console.Write(".");
                    Monitor.Wait(count_lock);
                }
            }

            foreach (var t in threads)
            {
                t.Join();
            }

            Console.WriteLine();
            iterations += 1;
        }

        Console.WriteLine($"done {iterations} iterations");
    }
コード例 #4
0
    public static void Main()
    {
        int         gcCount   = 0;
        int         joinCount = 0;
        TestTimeout timeout   = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));

        Thread gcThread = new Thread(() => {
            while (timeout.HaveTimeLeft)
            {
                GC.Collect();
                gcCount++;
                Thread.Sleep(1);
            }
        });

        gcThread.Start();

        // Create threads then join them for 1 seconds (120 for stress tests) nonstop while GCs occur once per ms
        while (timeout.HaveTimeLeft)
        {
            BlockingCollection <Thread> threads = new BlockingCollection <Thread> (new ConcurrentQueue <Thread> (), 128);

            Thread joinThread = new Thread(() => {
                for (int i = 0; ; ++i)
                {
                    Thread t = threads.Take();
                    if (t == null)
                    {
                        break;
                    }
                    t.Join();

                    // Uncomment this and run with MONO_LOG_LEVEL=info MONO_LOG_MASK=gc
                    // to see GC/join balance in real time
                    //Console.Write ("*");
                }
            });
            joinThread.Start();

            const int makeThreads = 10 * 1000;
            for (int i = 0; i < makeThreads; ++i)
            {
                Thread t = new Thread(() => { Thread.Yield(); });
                t.Start();

                threads.Add(t);
            }

            threads.Add(null);
            joinThread.Join();

            joinCount += makeThreads;
            Console.WriteLine("Performed {0} GCs, created {1} threads. Finished? {2}", gcCount, joinCount, !timeout.HaveTimeLeft);
        }
        gcThread.Join();
    }
コード例 #5
0
    static void CrossDomainTest(string name, CrossAppDomainDelegate dele)
    {
        TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));

        Console.WriteLine("----Testing {0}----", name);
        for (int i = 0; timeout.HaveTimeLeft; ++i)
        {
            var ad = AppDomain.CreateDomain(string.Format("domain-{0}-{1}", name, i));
            ad.DoCallBack(dele);
            AppDomain.Unload(ad);
        }
    }
コード例 #6
0
    public static void Main()
    {
        BlockingCollection <Thread> threads = new BlockingCollection <Thread> (128);

        Thread producer = new Thread(new ThreadStart(() => {
            DateTime start = DateTime.Now;

            for (TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 120 : 5)); timeout.HaveTimeLeft;)
            {
                Thread worker = new Thread(new ThreadStart(() => {
                    HashSet <string> hashset = new HashSet <string> ();
                    for (int i = 0; i < 50000; ++i)
                    {
                        hashset.Add(string.Concat(i, i));
                        if (i % 10 == 0)
                        {
                            Thread.Yield();
                        }
                    }
                }));

                worker.Start();

                threads.Add(worker);

                Console.WriteLine("Started thread {0} ({1} running concurrently)", worker.ManagedThreadId, threads.Count);
            }

            threads.CompleteAdding();
        }));

        Thread consumer = new Thread(new ThreadStart(() => {
            while (!threads.IsCompleted)
            {
                Thread worker = threads.Take();
                worker.Join();
                Console.WriteLine("Joined thread {0}", worker.ManagedThreadId);
            }
        }));

        producer.Start();
        consumer.Start();

        producer.Join();
        consumer.Join();
    }
コード例 #7
0
    public static void Main()
    {
        list_size = 1 << 15;
        TestTimeout timeout = TestTimeout.Start(TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));

        for (int it1 = 1; it1 <= 10; it1++, list_size <<= 1)
        {
            PinList list = MakeList(list_size);
            Console.WriteLine("long list constructed {0}", it1);
            for (int it2 = 0; it2 < 5; it2++)
            {
                Benchmark(list, 10 * it1);
                GC.Collect(1);

                if (!timeout.HaveTimeLeft)
                {
                    return;
                }
            }
        }
    }
コード例 #8
0
    static void Main()
    {
        var testTimeout = new TestTimeout();

        testTimeout.Start();
        for (int i = 0; i < Math.Max(1, Environment.ProcessorCount / 2); ++i)
        {
            // for (int i = 0; i < 4; ++i) {
            var t = new Thread(BackgroundNoise);
            t.IsBackground = true;
            t.Start();
        }

        const int TOTAL_ITERATIONS = 100;

        for (int i = 0; i < TOTAL_ITERATIONS; ++i)
        {
            var ad = AppDomain.CreateDomain("domain_" + i);
            ad.DoCallBack(new CrossAppDomainDelegate(AllocStuff));
            AppDomain.Unload(ad);

            Console.Write(".");
            if (i > 0 && i % 20 == 0)
            {
                Console.WriteLine();
            }

            if (!testTimeout.HaveTimeLeft())
            {
                var finishTime = DateTime.UtcNow;
                var ranFor     = finishTime - testTimeout.StartTime;
                Console.WriteLine("Will run out of time soon. ran for {0}, finished {1}/{2} iterations", ranFor, i + 1, TOTAL_ITERATIONS);
            }
        }
        Console.WriteLine("\ndone");
    }
コード例 #9
0
ファイル: VSTestAttributes.cs プロジェクト: bmourat/testfx
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeoutAttribute"/> class with a preset timeout
 /// </summary>
 /// <param name="timeout">
 /// The timeout
 /// </param>
 public TimeoutAttribute(TestTimeout timeout)
 {
     this.Timeout = (int)timeout;
 }
コード例 #10
0
    static void Main(string[] args)
    {
        var testTimeout = new TestTimeout();

        testTimeout.Start();

        const int TOTAL_ITERATIONS = 2;

        for (int j = 0; j < TOTAL_ITERATIONS; j++)
        {
            count = 0;

            List <Thread> threads             = new List <Thread>();
            List <System.Timers.Timer> timers = new List <System.Timers.Timer>();

            for (int i = 0; i < num_threads; i++)
            {
                Thread t3 = new Thread(delegate() {
                    UseMemory();
                });

                t3.Start();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed  += Timer_Elapsed;
                timer.AutoReset = false;
                timer.Interval  = 1000;
                timer.Start();
                timers.Add(timer);
            }

            for (int i = 0; i < 4000; i++)
            {
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed  += Timer_Elapsed;
                timer.AutoReset = false;
                timer.Interval  = 500;
                timer.Start();
                timers.Add(timer);
            }

            lock (count_lock)
            {
                while (count < num_threads)
                {
                    Console.Write(".");
                    Monitor.Wait(count_lock);
                }
            }

            foreach (var t in threads)
            {
                t.Join();
            }

            Console.WriteLine();
            if (!testTimeout.HaveTimeLeft())
            {
                var finishTime = DateTime.UtcNow;
                var ranFor     = finishTime - testTimeout.StartTime;
                Console.WriteLine("Will run out of time soon.  ran for {0}, finished {1}/{2} iterations", ranFor, j + 1, TOTAL_ITERATIONS);
            }
        }

        Console.WriteLine("done");
    }
コード例 #11
0
        public async void Given_Parameters_CreateOrUpdateWebTestAsync_ShouldReturn_Result(string name, string url, TestStatus testStatus, TestFrequency testFrequency, TestTimeout testTimeout, bool parseDependentRequests, RetriesForWebTestFailure retriesForWebTestFailure, AuthType authType, string accessToken, TestLocations testLocations, string resourceGroup, string location)
        {
            var successCriteria = new Mock <SucessCriteriaElement>();

            successCriteria.SetupGet(p => p.Timeout).Returns(testTimeout);

            this._webTest.SetupGet(p => p.TestType).Returns(TestType.UrlPingTest);
            this._webTest.SetupGet(p => p.Status).Returns(testStatus);
            this._webTest.SetupGet(p => p.Frequency).Returns(testFrequency);
            this._webTest.SetupGet(p => p.ParseDependentRequests).Returns(parseDependentRequests);
            this._webTest.SetupGet(p => p.SuccessCriteria).Returns(successCriteria.Object);
            this._webTest.SetupGet(p => p.RetriesForWebTestFailure).Returns(retriesForWebTestFailure);
            this._webTest.SetupGet(p => p.TestLocations).Returns(testLocations);

            this._appInsights.SetupGet(p => p.ResourceGroup).Returns(resourceGroup);

            this._settings.SetupGet(p => p.ApplicationInsight).Returns(this._appInsights.Object);

            var resource       = new GenericResourceExtended(location);
            var resourceResult = new ResourceCreateOrUpdateResult()
            {
                StatusCode = HttpStatusCode.OK, Resource = resource
            };

            this._resourceOperations.Setup(p => p.CreateOrUpdateAsync(It.IsAny <string>(), It.IsAny <ResourceIdentity>(), It.IsAny <GenericResource>(), It.IsAny <CancellationToken>())).ReturnsAsync(resourceResult);

            this._resourceClient.Setup(p => p.Resources).Returns(this._resourceOperations.Object);

            var id = Guid.NewGuid();
            var insightsResource = new ResourceBaseExtended(location)
            {
                Id = id.ToString(), Name = name
            };

            var result = await this._service.CreateOrUpdateWebTestAsync(name, url, authType, accessToken, this._webTest.Object, this._resourceClient.Object, insightsResource).ConfigureAwait(false);

            result.Location.Should().BeEquivalentTo(location);
        }
コード例 #12
0
    static void Main (string[] args) {
        var testTimeout = new TestTimeout ();
        testTimeout.Start ();

        const int TOTAL_ITERATIONS = 2;
        for (int j = 0; j < TOTAL_ITERATIONS; j++)
        {
            count = 0;

            List<Thread> threads = new List<Thread>();
            List<System.Timers.Timer> timers = new List<System.Timers.Timer>();

            for (int i = 0; i < num_threads; i++)
            {
                Thread t3 = new Thread (delegate () { 
                    UseMemory();
                    });

                t3.Start ();

                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed += Timer_Elapsed;
                timer.AutoReset = false;
                timer.Interval = 1000;
                timer.Start();
                timers.Add(timer);
            }
            
            for (int i = 0; i < 4000; i++)
            {
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed += Timer_Elapsed;
                timer.AutoReset = false;
                timer.Interval = 500;
                timer.Start();
                timers.Add(timer);
            }

            lock (count_lock)
            {
                while (count < num_threads)
                {
                    Console.Write (".");
                    Monitor.Wait(count_lock);
                }
            }

            foreach (var t in threads)
            {
                t.Join();
            }

            Console.WriteLine ();
            if (!testTimeout.HaveTimeLeft ()) {
                    var finishTime = DateTime.UtcNow;
                    var ranFor = finishTime - testTimeout.StartTime;
                    Console.WriteLine ("Will run out of time soon.  ran for {0}, finished {1}/{2} iterations", ranFor, j+1, TOTAL_ITERATIONS);
            }
        }

	Console.WriteLine ("done");
    }
コード例 #13
0
ファイル: TestSaga.cs プロジェクト: KqSMea8/gueslang
 public Task Timeout(TestTimeout state, IMessageHandlerContext context)
 {
     log.Info($"{Data.SomeId}: Got timeout. Completing.");
     MarkAsComplete();
     return(Task.CompletedTask);
 }
コード例 #14
0
        /// <summary>
        /// Creates a new instance of the web test properties inheriting the <see cref="WebTestProperties"/> class.
        /// </summary>
        /// <param name="testLocations"><see cref="TestLocations"/> value.</param>
        /// <param name="testStatus"><see cref="TestStatus"/> value.</param>
        /// <param name="testFrequency"><see cref="TestFrequency"/> value.</param>
        /// <param name="testTimeout"><see cref="TestTimeout"/> value.</param>
        /// <param name="parseDependentRequests">Value indicating whether to parse dependent requests or not.</param>
        /// <param name="retriesForWebTestFailure"><see cref="RetriesForWebTestFailure"/> value.</param>
        /// <param name="expectedHttpStatusCode">HTTP status code expected. Default value is <c>200</c>.</param>
        /// <param name="authType"><see cref="AuthType"/> value.</param>
        /// <param name="accessToken">Access token value.</param>
        /// <param name="text">Text to find in the validation rule.</param>
        public void CreateWebTestProperties(TestLocations testLocations, TestStatus testStatus, TestFrequency testFrequency, TestTimeout testTimeout, bool parseDependentRequests, RetriesForWebTestFailure retriesForWebTestFailure, int expectedHttpStatusCode = 200, AuthType authType = AuthType.None, string accessToken = null, string text = null)
        {
            WebTestProperties properties;

            switch (this._testType)
            {
            case TestType.UrlPingTest:
                properties = this.CreatePingWebTestProperties(testLocations, testStatus, testFrequency, testTimeout, parseDependentRequests, retriesForWebTestFailure, expectedHttpStatusCode, authType, accessToken, text);
                break;

            case TestType.MultiStepTest:
                properties = new MultiStepWebTestProperties();
                break;

            default:
                properties = null;
                break;
            }

            this.Properties = properties;
        }
コード例 #15
0
        private PingWebTestProperties CreatePingWebTestProperties(TestLocations testLocations, TestStatus testStatus, TestFrequency testFrequency, TestTimeout testTimeout, bool parseDependentRequests, RetriesForWebTestFailure retriesForWebTestFailure, int expectedHttpStatusCode = 200, AuthType authType = AuthType.None, string accessToken = null, string text = null)
        {
            var properties = new PingWebTestProperties()
            {
                Name          = this._name,
                Description   = string.Empty,
                TestStatus    = testStatus,
                TestFrequency = testFrequency,
                TestTimeout   = testTimeout,
                EnableRetriesForWebTestFailure = retriesForWebTestFailure,
                Locations          = WebTestLocations.GetWebTestLocations(testLocations),
                Configuration      = new PingWebTestConfiguration(this._name, this._url, (int)testTimeout, parseDependentRequests, expectedHttpStatusCode, authType, accessToken, text),
                SyntheticMonitorId = this._syntheticMonitorId,
            };

            return(properties);
        }