Skip to content
This repository was archived by the owner on Oct 26, 2026. It is now read-only.

imagej/image-ops2 test speedups - #65

Merged
ctrueden merged 5 commits into
mainfrom
imagej/imagej-ops2/test-speedups
Nov 8, 2022
Merged

ctrueden merged 5 commits into
mainfrom
imagej/imagej-ops2/test-speedups

Conversation

@hinerm

@hinerm hinerm commented Nov 7, 2022

Copy link
Copy Markdown
Member

Reduces imagej-ops unit test time required by a factor of three.

See scijava/scijava#102

Significantly speeds up tests
It is unnecessarily costly to load these images before EVERY test,
especially since they are unused in many tests.
@hinerm
hinerm requested review from ctrueden and gselzer November 7, 2022 14:35
@hinerm

hinerm commented Nov 7, 2022

Copy link
Copy Markdown
Member Author

@ctrueden @gselzer this PR creates a single OpEnvironment and eliminates some unnecessary opening of images from disk before unit tests that don't need them.

On my system imagej-ops tests run in less than a minute now. It's not perfect but is a reasonable improvement.

@gselzer gselzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @hinerm! These changes look good to me!

public abstract class AbstractOpTest{

protected static OpEnvironment ops;
protected static OpEnvironment ops = new DefaultOpEnvironment();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add final here, just in case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 62aa496. @hinerm Do you see any problem with doing this? I am not sure, but I could imagine that pushing the data structure construction earlier, to class initialization time rather than whenever JUnit calls the BeforeClass methods, could potentially alter behavior? Everything does still pass for me locally though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but I could imagine that pushing the data structure construction earlier, to class initialization time rather than whenever JUnit calls the BeforeClass methods, could potentially alter behavior?

That's a good point, but since it's only in the tests, we can change it later if we find that it's an issue, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's only in the tests, we can change it later if we find that it's an issue, no?

Definitely; that was my thinking as well.

@ctrueden ctrueden left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I followed up on one comment from @gselzer, and I also fixed some Windows line endings while at it. I think this PR is good to go! Merging now (after CI checks pass).

public abstract class AbstractOpTest{

protected static OpEnvironment ops;
protected static OpEnvironment ops = new DefaultOpEnvironment();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 62aa496. @hinerm Do you see any problem with doing this? I am not sure, but I could imagine that pushing the data structure construction earlier, to class initialization time rather than whenever JUnit calls the BeforeClass methods, could potentially alter behavior? Everything does still pass for me locally though.

@ctrueden
ctrueden merged commit 5e457c3 into main Nov 8, 2022
@ctrueden
ctrueden deleted the imagej/imagej-ops2/test-speedups branch November 8, 2022 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants