BendTests.A03_LayerManagerTests.WriteThreadsTest.runThreadedTest C# (CSharp) Метод

runThreadedTest() публичный Метод

public runThreadedTest ( int numthreads ) : void
numthreads int
Результат void
            public void runThreadedTest(int numthreads)
            {
                List<Thread> threads = new List<Thread>();

                for (int threadnum = 0; threadnum < numthreads; threadnum++) {
                    threadLauncher launcher = new threadLauncher(this, threadnum);
                    Thread newthread = new Thread(new ThreadStart(launcher.testThreadWorker));
                    threads.Add(newthread);
                }
                Thread checkpointer = new Thread(new ThreadStart(this.checkpointer));
                DateTime start = DateTime.Now;
                try {

                    checkpointer.Start();

                    num_additions = 0; num_removals = 0; num_retrievals = 0;

                    foreach (Thread th in threads) {
                        th.Start();
                    }

                    foreach (Thread th in threads) {
                        // rejoin the threads
                        th.Join();
                    }
                } finally {
                    // stop the checkpointer
                    checkpoint_interval = 0;
                }
                checkpointer.Join();

                double duration_ms = (DateTime.Now - start).TotalMilliseconds;
                double ops_per_sec = (num_additions + num_retrievals + num_removals) * (1000.0 / duration_ms);

                System.Console.WriteLine("LayerManager Threading Test, {0} ms elapsed",
                    duration_ms);
                System.Console.WriteLine("  {0} additions, {1} retrievals, {2} removals",
                    num_additions, num_retrievals, num_removals);
                System.Console.WriteLine("  {0} ops/sec", ops_per_sec);
                System.Console.WriteLine("  {0} exceptions", exceptions);

                int expected_count = numthreads * datavalues.Length;
                Assert.AreEqual(expected_count, num_additions, "addition count");
                Assert.AreEqual(expected_count, num_retrievals, "retrieval count");
                Assert.AreEqual(expected_count, num_removals, "removal count");
                Assert.AreEqual(exceptions, 0, "exceptions");
            }

Usage Example

Пример #1
0
 public void T11_WriteThreads_Perf()
 {
     A03_LayerManagerTests.WriteThreadsTest test =
         new A03_LayerManagerTests.WriteThreadsTest(500, 7000, withMerge:true);
     test.runThreadedTest(60);
     test.Dispose();
 }
All Usage Examples Of BendTests.A03_LayerManagerTests.WriteThreadsTest::runThreadedTest