fest-assert-2.x icon indicating copy to clipboard operation
fest-assert-2.x copied to clipboard

IterableAssert.doesNotHaveDuplicates became unsable with many elements

Open thomas-hilaire opened this issue 12 years ago • 1 comments

Hello,

I used fest in my projects at a snapshot version : 44bf124d011b0f35a3add2be57a30fd8a372876a FEST-258 : fix NPE that would occur if error stack trace filtering is enabled and we JUnit is not in the classpath

I encountered a performance issue with Fest 2.0M8 in *IterableAssert.doesNotHaveDuplicates method. I made a small bench using a simple unit test to compare these versions :

Test :

@Test
public void testManyGeneration() {
    Stopwatch stopwatch = new Stopwatch().start();
    int generationCount = 10000;

    List<String> generated = Lists.newArrayListWithExpectedSize(generationCount);
    for (int count = 0; count < generationCount; count++) {
        generated.add(UUID.randomUUID().toString());
    }

    assertThat(generated).doesNotHaveDuplicates();
    System.out.println("Time elapsed in ms : " + stopwatch.stop().elapsedMillis());
}

Result :

version 2.0M8 : 10000 entries => Time elapsed in ms : 1907 100000 entries => Time elapsed in ms : 418619

version 44bf124d011b0f35a3add2be57a30fd8a372876a : 10000 entries => Time elapsed in ms : 198 100000 entries => Time elapsed in ms : 629

Can you improve the new version of doesNotHaveDuplicates method ?

Thanks for your library which is part of our DSL now, so appreciated ! Thomas

thomas-hilaire avatar Nov 06 '12 17:11 thomas-hilaire

Hi, Just to let you know that this issue has been solved in AssertJ core in 1.2.0 release (AssertJ is a fork of Fest Assert). It is not yet solved in Fest (the previous github automatic comment may be confusing).

Regards,

Joel Costigliola

joel-costigliola avatar May 12 '13 18:05 joel-costigliola