AdoptOpenJDK / jitwatch

Log analyser / visualiser for Java HotSpot JIT compiler. Inspect inlining decisions, hot methods, bytecode, and assembly. View results in the JavaFX user interface.
Other
3.1k stars 440 forks source link

refactor the @Before/@After to make a test faster #384

Closed TestBoost closed 11 months ago

TestBoost commented 11 months ago

The tests in the test class TestBytecodeLoaderWithInnerClasses tries to compile a Java file into bytecodes and then uses BytecodeLoader to load the compiled bytecodes. However, among all the tests in this test class, there are no modifications on the compiled bytecodes and the fields defined in this test class.

When running this test, all tests repeatly compile the Java file and load the bytecodes, which add a huge cost to this test. Thus, we propose to just run the @Before and @After method once for the tests in this test class.

The time to run all the tests in the test class TestBytecodeLoaderWithInnerClasses can jump from 4.370 s to 0.491 s on our local machine.

chriswhocodes commented 11 months ago

Hi @TestBoost thanks for this PR. I agree, that expensive setup only needs to happen once per test class not per test method.

If this is a bot account please can you confirm you're happy for your contribution to be licensed under the BSD 2-clause license?

Thanks,

Chris

TestBoost commented 11 months ago

Hi Chris,

Thank you for your response!

I am not a bot haha. But I am happy to be licensed under the BSD 2-clause license.

Thanks, TestBoost

chriswhocodes commented 11 months ago

Thanks @TestBoost I've merged your patch.