imglib / imglib2-roi

Regions of interest (ROIs) and labelings for ImgLib2
Other
9 stars 8 forks source link

Fix IntersectionRealInterval and IntersectionInterval performance #62

Closed tischi closed 2 years ago

tischi commented 2 years ago

One also needs to fix the performance issue for UnionRealInterval and UnionInterval but this is pending on https://github.com/imglib/imglib2/issues/300 and, depending on the outcome there, it may not be as straightforward to improve the performance. Thus I would do this is in a separate PR.

tischi commented 2 years ago

@ctrueden I thought a bit about it and I think we should add a mechanism in the performance test that kills the test if it runs too long and returns a failed test, otherwise it could just hang forever, e.g., on the CI.

Would something like this make sense?

    ExecutorService service = Executors.newCachedThreadPool();
    Future future = service.submit( myRunnableTest );

    boolean success = true;
    long startTime = System.currentTimeMillis();
    while (!future.isDone()) {
        if (System.currentTimeMillis() - startTime > 5000) {
            future.cancel(true);
            success = false;
            break;
        }
    } 
    service.shutDown();

    assertTrue(success);
ctrueden commented 2 years ago

@tischi Researching this, I learned that JUnit has a timeout feature built-in; see https://stackoverflow.com/q/57116801/1207769. Would that work for us here?

tischi commented 2 years ago

@ctrueden

That works:

@Test(timeout=5000)

I added it to the tests. From my side I think this could be merged now.

ctrueden commented 2 years ago

Great, thank you so much!