What's good fam. I'm trying to debug a weird perfo...
# community-support
m
What's good fam. I'm trying to debug a weird performance issue in a gradle project. Here is the scan I'll be referring to: https://scans.gradle.com/s/gfqck3xlctvns/tests/overview The scan shows a test run of a single junit test class. It's important to note that this test class does nothing special, nothing complicated, no delays, no sleeps, no synchronizations, etc - just mocking a few objects and verifying correct usage. The first run of this test class is always slow, on the order of seconds, and the others in the class perform to my expectations, in the order of a few milliseconds. Anything off the top of our heads I should look into to debug first? I've tried increasing memory/heapsize, enabling parallel execution with
maxParallelForks
(from Gradle's docs), setting
forkEvery
to both
0
and
1
, using different JDK versions (
11
and
17
), but no smoking gun yet.
Also of note: I could generate scans for other junit classes and they have the same behavior. The first test method is slow (500ms+), and the others are much faster (~50ms). I understand the first execution takes a hit for initialization purposes, but the delta seems fishy
n
how are you mocking? do you happen to use mockito and its
MockitoExtension
?
https://github.com/mockito/mockito/issues/1509 <-- you probably suffer from this in that case
👀 1
m
Forgot to check the mock extension - yeah we have a
resources/mockito-extensions/org.mockito.plugins.MockMaker
file with
mock-maker-inline
. Should probably just be using
mockito-inline
I suppose?
I'll check the usage of mocks and reset them and see if that results in any impact!
Looks like
mockito-inline
is the default as of
mockito-5+
n
In general I'd advise to stay away from the annotation-based mocking when using mockito. It requires a full classpath scan, which can have significant impact on init times.
m
This test and others are using
mock<ClassThing>
not the
@Mock
annotation so doesn't look like that issue applies here, although I appreciate the link
👌 1
I've narrowed it down to something with Mockito in general - using fakes instead of mocks is much faster, which makes sense, but the magnitude of difference is kinda wild