Hi Hamlin,

Conservatively I would prefer not to remove data sets if at all possible. It 
will affect all tests, and leaf tasks for parallel streams should have enough 
data to crunch on.

I suspect the problem of the flatMap test is not necessarily due to the source 
sizes being of 1000 elements but that there are tests that substitute an 
element whose value is m for n elements from 0..m, which can explode things and 
generate lots of garbage.

Have you tried executing those kinds tests when the data size is < 1000?

My bet is the FlatMapOpTest will run significantly faster and you will not need 
to split it out.

There are two ways we could consider doing this:

1) Check the size in the test method:

if (data.size() < 1000) {
    exerciseOps(data, s -> s.flatMap(mfLt));
    exerciseOps(data, s -> s.flatMap(integerRangeMapper));
    exerciseOps(data, s -> s.flatMap((Integer e) -> IntStream.range(0, 
e).boxed().limit(10)));
}

2) Include a new data provider for smaller data sets

@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = 
StreamTestDataProvider.class)
public void testOps(String name, TestData.OfRef<Integer> data) {
    Collection<Integer> result = exerciseOps(data, s -> s.flatMap(mfId));
    assertEquals(data.size(), result.size());

    result = exerciseOps(data, s -> s.flatMap(mfNull));
    assertEquals(0, result.size());

    result = exerciseOps(data, s-> s.flatMap(e -> Stream.empty()));
    assertEquals(0, result.size());
}

@Test(dataProvider = "StreamTestData<Integer>.small", dataProviderClass = 
StreamTestDataProvider.class)
public void testOpsX(String name, TestData.OfRef<Integer> data) {
    exerciseOps(data, s -> s.flatMap(mfLt));
    exerciseOps(data, s -> s.flatMap(integerRangeMapper));
    exerciseOps(data, s -> s.flatMap((Integer e) -> IntStream.range(0, 
e).boxed().limit(10)));
}

I prefer the latter approach (applied to ref and primitive data sets). It’s 
more work, but i think the right direction.

Paul.

> On 26 Jan 2016, at 08:08, Hamlin Li <huaming...@oracle.com> wrote:
> 
> Hi everyone,
> 
> Would you please help to review the fix for bug 
> https://bugs.openjdk.java.net/browse/JDK-8076458, 
> java/util/stream/test/org/openjdk/tests/java/util/stream/FlatMapOpTest.java 
> timeout.
> webrev: http://cr.openjdk.java.net/~mli/8076458/webrev.00/
> 
> Thank you
> -Hamlin

Reply via email to