alexruiz / fest-assert-2.x

FEST Fluent Assertions 2.x
http://fest.easytesting.org
Apache License 2.0
402 stars 69 forks source link

IterableAssert.doesNotHaveDuplicates became unsable with many elements #122

Open thomas-hilaire opened 11 years ago

thomas-hilaire commented 11 years ago

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

joel-costigliola commented 11 years ago

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