Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

improved comments readability, added PerformanceTest

  • Loading branch information...
commit 7dfcdaf3778cfb1c73ea6617f92c5de39de6efc7 1 parent 51cdda4
@Tibor17 authored
View
97 src/main/java/org/junit/experimental/ParallelComputer.java
@@ -69,58 +69,79 @@
* @see <a href="https://github.com/KentBeck/junit/wiki/ParallelComputer">ParallelComputer at JUnit wiki</a>
*/
public class ParallelComputer extends Computer {
- // true: parallelized classes if #classes(), #classesAndMethods() or ParallelComputer(true, x), ParallelComputer(pool[,...])
+
+ /**
+ * {@code true} if has to run classes in parallel.
+ */
private final boolean fParallelClasses;
- // true: parallelized methods if #methods(), #classesAndMethods() or ParallelComputer(x, true), ParallelComputer(x, pool), ParallelComputer(pool[,...])
+ /**
+ * {@code true} if has to run methods in parallel.
+ */
private final boolean fParallelMethods;
- // true if a pool is provided by caller: #classes(pool), #methods(pool), #classesAndMethods(pool[,...]), ParallelComputer(pool[,...])
- // else a pool is created (same as previous implementation), see #threadPoolClasses() and #threadPoolMethods()
+ /**
+ * {@code true} if called a factory method which specifies a thread pool.
+ */
private final boolean fProvidedPools;
- // true if provided pool is one common for methods/classes; enables the fSinglePoolBalancer
+ /**
+ * {@code true} if {@link #classesAndMethods(ThreadPoolExecutor)} or {@link #classesAndMethods(ThreadPoolExecutor, int)}.
+ */
private final boolean fHasSinglePoll;
- // if single pool, ThreadPoolExecutor#getCorePoolSize(); necessary to compute thread resources for classes/methods, see #getSuite()
+ /**
+ * Is {@link ThreadPoolExecutor#getCorePoolSize()} if {@link #fHasSinglePoll} is set.
+ * To compute num of parallel methods {@link #fSinglePoolMinConcurrentMethods} in single pool #classesAndMethods().
+ */
private final int fSinglePoolCoreSize;
- // if single pool, ThreadPoolExecutor#getMaximumPoolSize(); necessary to compute thread resources for classes/methods, see #getSuite()
+ /**
+ * {@link ThreadPoolExecutor#getMaximumPoolSize()} if {@link #fHasSinglePoll} is set. To compute num of parallel methods.
+ */
private final int fSinglePoolMaxSize;
- // if single pool, the user can specify min concurrent methods. Without this the parallel classes consumed all thread resources.
private final int fSinglePoolMinConcurrentMethods;
- // provided pools
- // if a single pool, both refer to the same
+ /**
+ * Thread pools if specified in factories.
+ */
private final ExecutorService fPoolClasses;
private final ExecutorService fPoolMethods;
+ /**
+ * To return executed parents and children before {@link #shutdown(boolean)}.
+ */
private final ConcurrentLinkedQueue<Description> fBeforeShutdown= new ConcurrentLinkedQueue<Description>();
- //set if a pool is shut down externally
+ /**
+ * {@code true} if shutdown.
+ */
private final AtomicBoolean fIsShutDown= new AtomicBoolean(false);
- // Used if fHasSinglePoll is set. Disables this Thread for scheduling purposes until all classes finished.
+ /**
+ * If {@link #fHasSinglePoll}, waiting in {@link RunnerScheduler#finished()} until all classes have completed.
+ */
private volatile CountDownLatch fClassesFinisher;
- // prevents thread resources exhaustion on classes when used with single pool => gives a chance to parallelize methods
- // see fSinglePoolMinConcurrentMethods above
- // used in #tryParallelize(): allows a number of parallel classes and methods
+ /**
+ * If {@link #fHasSinglePoll}, ensures min num of parallel methods is {@link #fSinglePoolMinConcurrentMethods}.
+ * Prevents from all thread resources exhaustion in favor of parallel classes.
+ */
private volatile Semaphore fSinglePoolBalancer;
- // fClassesFinisher is initialized with this value, see #getSuite() and #getParent()
private volatile int fCountClasses;
/**
* @deprecated As of JUnit 4.12, replace by {@link #methods()}, {@link #classes()}
* and {@link #classesAndMethodsUnbounded()}.
*/
- @Deprecated//should be private
+ @Deprecated
public ParallelComputer(boolean classes, boolean methods) {
+ // to satisfy JVM spec -write operation first on volatile fields
fClassesFinisher= null;
fSinglePoolBalancer= null;
- fCountClasses= 0;//to satisfy JVM spec -write operation first on volatile fields
+ fCountClasses= 0;
fParallelClasses= classes;
fParallelMethods= methods;
fPoolClasses= null;
@@ -143,9 +164,10 @@ private ParallelComputer(ThreadPoolExecutor pool, int minConcurrentMethods) {
private ParallelComputer(ExecutorService poolClasses, ExecutorService poolMethods,
int singlePoolCoreSize, int singlePoolMaxSize,
int minConcurrentMethods) {
+ // to satisfy JVM spec -write operation first on volatile fields
fClassesFinisher= null;
fSinglePoolBalancer= null;
- fCountClasses= 0;//to satisfy JVM spec -write operation first on volatile fields
+ fCountClasses= 0;
if (poolClasses == null && poolMethods == null) {
throw new NullPointerException("null classes/methods executor");
@@ -246,7 +268,7 @@ public static ParallelComputer classesAndMethodsBounded(int nThreads) {
* @return computer parallelized by given pool
* @throws IllegalArgumentException if <tt>maximumPoolSize &lt; 2</tt>;
* or <tt>corePoolSize &lt; 2</tt> for fixed-size pool
- * @throws IllegalStateException if the pool is already shut down
+ * @throws IllegalStateException if the pool is already shutdown
* @throws NullPointerException <tt>pool</tt> is null
*/
public static ParallelComputer classesAndMethods(ThreadPoolExecutor pool) {
@@ -262,7 +284,7 @@ public static ParallelComputer classesAndMethods(ThreadPoolExecutor pool) {
* @throws IllegalArgumentException if <tt>maximumPoolSize &lt; 2</tt>;
* or <tt>corePoolSize &lt; 2</tt> for fixed-size pool;
* or <tt>minConcurrentMethods &lt; 1<tt>
- * @throws IllegalStateException if the pool is already shut down
+ * @throws IllegalStateException if the pool is already shutdown
* @throws NullPointerException <tt>pool</tt> is null
*/
public static ParallelComputer classesAndMethods(ThreadPoolExecutor pool, int minConcurrentMethods) {
@@ -325,16 +347,18 @@ public void schedule(Runnable childStatement) {
fBeforeShutdown.add(runner.getDescription());
}
} catch (RejectedExecutionException e) {
- /*after external shut down*/
+ // after external shutdown
shutdownQuietly(false);
}
}
public void finished() {
- if (isClasses) { //wait until all test cases finished
+ if (isClasses) {
+ // wait until all test cases finished
awaitClassesFinished();
tryFinish(service);
- } else { //wait until the test case finished
+ } else {
+ // wait until the test case finished
if (fProvidedPools) {
awaitClassFinished(fMethodsFutures);
if (fHasSinglePoll) {
@@ -367,7 +391,7 @@ public Runner getSuite(RunnerBuilder builder, Class<?>[] classes) throws Initial
if (fHasSinglePoll) {
int maxConcurrentClasses;
if (fSinglePoolCoreSize == 0 || fSinglePoolCoreSize == fSinglePoolMaxSize) {
- //is unbounded or fixed-size single pool
+ // is unbounded or fixed-size single pool
maxConcurrentClasses= fSinglePoolMaxSize - fSinglePoolMinConcurrentMethods;
} else {
maxConcurrentClasses= Math.max(1, fSinglePoolCoreSize - fSinglePoolMinConcurrentMethods);
@@ -385,7 +409,8 @@ public Runner getSuite(RunnerBuilder builder, Class<?>[] classes) throws Initial
protected Runner getRunner(RunnerBuilder builder, Class<?> testClass) throws Throwable {
Runner runner= super.getRunner(builder, testClass);
if (canSchedule(runner)) {
- ++fCountClasses;//incremented without been AtomicInteger because not yet concurrent access
+ // incremented without been AtomicInteger because not yet concurrent access
+ ++fCountClasses;
tryParallelize((ParentRunner) runner, threadPoolMethods(), false);
}
return runner;
@@ -424,17 +449,18 @@ private ExecutorService threadPoolMethods() {
}
private void awaitClassFinished(Queue<Future<?>> methodsFutures) {
- if (methodsFutures != null) {//fParallelMethods is false
+ if (methodsFutures != null) {
+ // fParallelMethods should be false
for (Future<?> methodFuture : methodsFutures) {
try {
methodFuture.get();
} catch (InterruptedException e) {
- /*after called external ExecutorService#shutdownNow()*/
+ // after called external ExecutorService#shutdownNow()
shutdownQuietly(true);
} catch (ExecutionException e) {
- /*cause fired in run-notifier*/
+ // test throws exception
} catch (CancellationException e) {
- /*cannot happen because not calling Future#cancel(boolean)*/
+ // cannot happen because not calling Future#cancel()
}
}
}
@@ -487,13 +513,14 @@ private void stopScheulingTasks() {
*/
private void shutdownQuietly(boolean shutdownNow) {
try {
- if (fIsShutDown.compareAndSet(false, true)) {//let other threads avoid submitting new tasks
+ // let other threads avoid submitting new tasks
+ if (fIsShutDown.compareAndSet(false, true)) {
if (fHasSinglePoll && fCountClasses > 0) {
- //let dormant class-threads wake up and escape from balancer
+ // let dormant class-threads wake up and escape from balancer
fSinglePoolBalancer.release(fCountClasses);
- //cached a value in volatile field to the stack as a constant for faster reads
+ // cached a value in volatile field to the stack as a constant for faster reads
final CountDownLatch classesFinisher= fClassesFinisher;
- //signals that the total num classes could not be reached
+ // signals that the total num of classes could not be reached
while (classesFinisher.getCount() > 0) {
classesFinisher.countDown();
}
@@ -510,7 +537,7 @@ private void shutdownQuietly(boolean shutdownNow) {
}
}
} catch (Throwable t) {
- //may be only OOM, security and permission exceptions
+ // may be only OOM, security and permission exceptions
t.printStackTrace(System.err);
}
}
View
2  src/test/java/org/junit/tests/AllTests.java
@@ -25,6 +25,7 @@
import org.junit.tests.experimental.parallel.ParallelMethodTest;
import org.junit.tests.experimental.parallel.ParallelClassesAndMethodsTest;
import org.junit.tests.experimental.parallel.ParallelComputerShutDownTest;
+import org.junit.tests.experimental.parallel.PerformanceTest;
import org.junit.tests.experimental.rules.BlockJUnit4ClassRunnerOverrideTest;
import org.junit.tests.experimental.rules.ClassRulesTest;
import org.junit.tests.experimental.rules.ExpectedExceptionTest;
@@ -147,6 +148,7 @@
ParallelMethodTest.class,
ParallelClassesAndMethodsTest.class,
ParallelComputerShutDownTest.class,
+ PerformanceTest.class,
ParentRunnerTest.class,
NameRulesTest.class,
ClassRulesTest.class,
View
71 src/test/java/org/junit/tests/experimental/parallel/ParallelClassesAndMethodsTest.java
@@ -86,7 +86,7 @@
public static class Erroneous {
@Rule static final TestName testName= new TestName();
- //intended error in rule -no public instance member
+ // intended error in rule -no public instance member
@Test public void test() {}
}
@@ -155,11 +155,16 @@ public void init() {
}
@Test public void runParallelOversize() throws InterruptedException {
- fSynchronizer= new CyclicBarrier(6);//continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
- ThreadPoolExecutor pool= new ThreadPoolExecutor(0, 11,// 11 => more than (six thread parties in barrier + three concurrent classes)
- Long.MAX_VALUE, TimeUnit.NANOSECONDS,//don't reuse threads
- new SynchronousQueue<Runnable>());//default like for unbounded pools
- Computer comp= ParallelComputer.classesAndMethods(pool, 7);//capacity: 7 concurrent methods and 4 concurrent classes
+ // continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
+ fSynchronizer= new CyclicBarrier(6);
+ // 11 => more than (six thread parties in barrier + three concurrent classes)
+ ThreadPoolExecutor pool= new ThreadPoolExecutor(0, 11,
+ // don't reuse threads
+ Long.MAX_VALUE, TimeUnit.NANOSECONDS,
+ // default like for unbounded pools
+ new SynchronousQueue<Runnable>());
+ // capacity: 7 concurrent methods and 4 concurrent classes
+ Computer comp= ParallelComputer.classesAndMethods(pool, 7);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -173,16 +178,21 @@ public void init() {
fExample2One, fExample2Two,
fExample3One, fExample3Two);
assertThat(threads.size(), is(6));
- //should be 6 == number of thread parties in CyclicBarrier == number of concurrent methods
- //7 == capacity, we give the Computer a chance to excess the number of concurrent methods if fails
+ // should be 6 == number of thread parties in CyclicBarrier == number of concurrent methods
+ // 7 == capacity, we give the Computer a chance to excess the number of concurrent methods if fails
}
@Test public void runParallel() throws InterruptedException {
- fSynchronizer= new CyclicBarrier(6);//continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
- ThreadPoolExecutor pool= new ThreadPoolExecutor(0, 9,// 9 == (six thread parties in barrier + three concurrent classes)
- Long.MAX_VALUE, TimeUnit.NANOSECONDS,//don't reuse threads
- new SynchronousQueue<Runnable>());//default like for unbounded pools
- Computer comp= ParallelComputer.classesAndMethods(pool, 6);//capacity: 6 concurrent methods and 3 concurrent classes
+ // continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
+ fSynchronizer= new CyclicBarrier(6);
+ // 9 == (six thread parties in barrier + three concurrent classes)
+ ThreadPoolExecutor pool= new ThreadPoolExecutor(0, 9,
+ // don't reuse threads
+ Long.MAX_VALUE, TimeUnit.NANOSECONDS,
+ // default like for unbounded pools
+ new SynchronousQueue<Runnable>());
+ // capacity: 6 concurrent methods and 3 concurrent classes
+ Computer comp= ParallelComputer.classesAndMethods(pool, 6);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -196,15 +206,18 @@ public void init() {
fExample2One, fExample2Two,
fExample3One, fExample3Two);
assertThat(threads.size(), is(6));
- //should be 6 == number of thread parties in CyclicBarrier == number of concurrent methods
+ // should be 6 == number of thread parties in CyclicBarrier == number of concurrent methods
}
@Test public void runParallelUndersized() throws InterruptedException {
fSynchronizer= null;
ThreadPoolExecutor pool= new ThreadPoolExecutor(3, 4,
- 0, TimeUnit.NANOSECONDS,//reuse threads
- new LinkedBlockingQueue<Runnable>());//default like for unbounded pools
- Computer comp= ParallelComputer.classesAndMethods(pool, 2);//capacity: 2 concurrent methods at least, and 1 or 2 concurrent classes
+ // reuse threads
+ 0, TimeUnit.NANOSECONDS,
+ // default like for unbounded pools
+ new LinkedBlockingQueue<Runnable>());
+ // capacity: 2 concurrent methods at least, and 1 or 2 concurrent classes
+ Computer comp= ParallelComputer.classesAndMethods(pool, 2);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -222,7 +235,8 @@ public void init() {
@Test public void runParallelMinimum() throws InterruptedException {
fSynchronizer= null;
- Computer comp= ParallelComputer.classesAndMethodsBounded(2);//capacity: 1 concurrent method, and 1 concurrent class
+ // capacity: 1 concurrent method, and 1 concurrent class
+ Computer comp= ParallelComputer.classesAndMethodsBounded(2);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -242,7 +256,8 @@ public void init() {
}
@Test public void classesAndMethodsUnbounded() {
- fSynchronizer= new CyclicBarrier(6);//continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
+ // continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
+ fSynchronizer= new CyclicBarrier(6);
Computer comp= ParallelComputer.classesAndMethodsUnbounded();
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
@@ -260,8 +275,10 @@ public void init() {
}
@Test public void classesAndMethodsBounded() throws InterruptedException {
- fSynchronizer= new CyclicBarrier(6);//continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
- Computer comp= ParallelComputer.classesAndMethodsBounded(10);//min capacity: 6 concurrent methods, and 3 concurrent classes
+ // continue with tests if 6 threads for methods are scheduled until timeout; otherwise fail
+ fSynchronizer= new CyclicBarrier(6);
+ // min capacity: 6 concurrent methods, and 3 concurrent classes
+ Computer comp= ParallelComputer.classesAndMethodsBounded(10);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -279,7 +296,8 @@ public void init() {
@Test public void classesAndMethodsBoundedUndersized() throws InterruptedException {
fSynchronizer= null;
- Computer comp= ParallelComputer.classesAndMethodsBounded(4);//1 - 3 concurrent methods
+ // 1 - 3 concurrent methods
+ Computer comp= ParallelComputer.classesAndMethodsBounded(4);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -299,7 +317,8 @@ public void init() {
fSynchronizer= null;
ExecutorService poolClasses= Executors.newSingleThreadExecutor();
ExecutorService poolMethods= Executors.newSingleThreadExecutor();
- Computer comp= ParallelComputer.classesAndMethods(poolClasses, poolMethods);//nothing much parallelized
+ // nothing much parallelized
+ Computer comp= ParallelComputer.classesAndMethods(poolClasses, poolMethods);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -319,7 +338,8 @@ public void init() {
fSynchronizer= new CyclicBarrier(2);
ExecutorService poolClasses= Executors.newFixedThreadPool(3);
ExecutorService poolMethods= Executors.newFixedThreadPool(2);
- Computer comp= ParallelComputer.classesAndMethods(poolClasses, poolMethods);//2 Threads / class
+ // 2 Threads / class
+ Computer comp= ParallelComputer.classesAndMethods(poolClasses, poolMethods);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
@@ -339,7 +359,8 @@ public void init() {
fSynchronizer= new CyclicBarrier(3);
ExecutorService poolClasses= Executors.newFixedThreadPool(5);
ExecutorService poolMethods= Executors.newFixedThreadPool(4);
- Computer comp= ParallelComputer.classesAndMethods(poolClasses, poolMethods);//3 or 4 method Threads
+ // 3 or 4 method Threads
+ Computer comp= ParallelComputer.classesAndMethods(poolClasses, poolMethods);
Result result= JUnitCore.runClasses(comp, Example1.class, Example2.class, Example3.class);
assertTrue(result.wasSuccessful());
assertNotNull(fExample1One);
View
42 src/test/java/org/junit/tests/experimental/parallel/PerformanceTest.java
@@ -44,73 +44,85 @@ public void fast() throws InterruptedException {
public static class SlowAndFast2 extends SlowAndFast1 {}
@Test
- public void sequenceSlow() {//takes four seconds to complete
+ public void sequenceSlow() {
+ // takes four seconds to complete
Result result= JUnitCore.runClasses(Slow1.class, Slow2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void sequenceSlowAndFast() {//takes four seconds to complete
+ public void sequenceSlowAndFast() {
+ // takes four seconds to complete
Result result= JUnitCore.runClasses(SlowAndFast1.class, SlowAndFast2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClassesAndMethods() {//for Javadoc. Takes one second.
+ public void parallelClassesAndMethods() {
+ // for Javadoc. Takes one second.
Result result= JUnitCore.runClasses(ParallelComputer.classesAndMethodsUnbounded(), Slow1.class, Slow2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClasses() {//for Javadoc. Takes two seconds.
+ public void parallelClasses() {
+ // for Javadoc. Takes two seconds.
Result result= JUnitCore.runClasses(ParallelComputer.classes(), Slow1.class, Slow2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelMethods() {//for Javadoc. Takes two seconds.
+ public void parallelMethods() {
+ // for Javadoc. Takes two seconds.
Result result= JUnitCore.runClasses(ParallelComputer.methods(), Slow1.class, Slow2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClasses1() {//takes two seconds to complete
+ public void parallelClasses1() {
+ // takes two seconds to complete
Result result= JUnitCore.runClasses(ParallelComputer.classes(), Slow1.class, Slow2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClasses2() {//takes two seconds to complete
+ public void parallelClasses2() {
+ // takes two seconds to complete
Result result= JUnitCore.runClasses(ParallelComputer.classes(Executors.newFixedThreadPool(2)), Slow1.class, Slow2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelMethods1() {//takes two seconds to complete, executes three threads
+ public void parallelMethods1() {
+ // takes two seconds to complete, executes three threads
Result result= JUnitCore.runClasses(ParallelComputer.methods(), SlowAndFast1.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelMethods2() {//takes two seconds to complete
+ public void parallelMethods2() {
+ // takes two seconds to complete
Result result= JUnitCore.runClasses(ParallelComputer.methods(Executors.newFixedThreadPool(2)), SlowAndFast1.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClassesAndMethodsUnbounded() {//takes two seconds to complete
+ public void parallelClassesAndMethodsUnbounded() {
+ // takes two seconds to complete
Result result= JUnitCore.runClasses(ParallelComputer.classesAndMethodsUnbounded(), SlowAndFast1.class, SlowAndFast2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClassesAndMethodsBounded1() {//takes two seconds to complete
+ public void parallelClassesAndMethodsBounded1() {
+ // takes two seconds to complete
Result result= JUnitCore.runClasses(ParallelComputer.classesAndMethodsBounded(8), SlowAndFast1.class, SlowAndFast2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClassesAndMethodsBounded2() {//takes two seconds to complete
+ public void parallelClassesAndMethodsBounded2() {
+ // takes two seconds to complete
ThreadPoolExecutor pool= new ThreadPoolExecutor(8, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
Computer cmp= ParallelComputer.classesAndMethods(pool);
Result result= JUnitCore.runClasses(cmp, SlowAndFast1.class, SlowAndFast2.class);
@@ -118,14 +130,16 @@ public void parallelClassesAndMethodsBounded2() {//takes two seconds to complete
}
@Test
- public void parallelClassesAndMethods1() {//takes 2.5 second to complete
+ public void parallelClassesAndMethods1() {
+ // takes 2.5 second to complete
ThreadPoolExecutor pool= new ThreadPoolExecutor(6, 6, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
Result result= JUnitCore.runClasses(ParallelComputer.classesAndMethods(pool, 4), SlowAndFast1.class, SlowAndFast2.class);
assertTrue(result.wasSuccessful());
}
@Test
- public void parallelClassesAndMethods2() {//takes 2.5 second to complete
+ public void parallelClassesAndMethods2() {
+ // takes 2.5 second to complete
Computer cmp= ParallelComputer.classesAndMethods(Executors.newFixedThreadPool(2), Executors.newFixedThreadPool(4));
Result result= JUnitCore.runClasses(cmp, SlowAndFast1.class, SlowAndFast2.class);
assertTrue(result.wasSuccessful());
Please sign in to comment.
Something went wrong with that request. Please try again.