How is the performance state in Mockk? <https://gi...
# mockk
k
How is the performance state in Mockk? https://github.com/mockk/mockk/issues/13 Any recent performance improvements?
m
there haven’t been any updates performance-wise recently - some new discussion in that thread, but no big changes in the codebase. I’m happy to review PRs that improve performances though 🙂
t
I was looking at this recently too, as there are some unit tests that start in 10 seconds for us (in CI, locally it is 3 seconds). I tried https://github.com/mockk/mockk/issues/13#issuecomment-990960670 but not sure I did it right and it had no impact unfortunately 😞 get rates 20.350s passed no rates 1.895s passed this is the most blatant one we have, though it uses kotest
import io.kotest.extensions.time.withConstantNow
Copy code
test("get rates") {
  withConstantNow(LocalDate.now()) {
    ...
  }
}
k
@thanksforallthefish It seems still there is a perf problem, imagine it being multiplied with # tests,
there are some unit tests that start in 10 seconds for us (in CI, locally it is 3 seconds). I tried
Is 3 seconds for single test?
t
yes. I think it is all described in the ticket linked above, the issue is with bytebuddy initialization (I think). The first test might take a very long time, subsequent tests in same file/spec are as fast as expected from ut, so order of ms. static mockks seem particularly bad, but to be honest I have not really looked into it because 1. I don't have the skills 2. we run unit and integration tests as separate gradle source sets in parallel, thus we don't feel the pain as we anyway have to wait for integration tests to run