Skip to content

Improving performance when creating many mocks #520

Answered by LandonTClipp
manzanit0 asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately there are not many. The main problem comes from packages.Load which is doing the actual AST parsing. There have been various hacks suggested that I didn't like for various reasons. We've done what the maintainers have suggested with caching the Loads to avoid re-parsing the same thing multiple times: https://github.com/vektra/mockery/blob/v2.15.0/pkg/parse.go#L53

yet it doesn't help much. This is also not a problem unique to mockery:

golang/go#31087

cogentcore/cogent#150

Here's an explanation of the problem: golang/go#31087

One of the other potential issues is that packages.Load is loading the entire dep tree of every single file in your package, which would mean parsing the…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@manzanit0
Comment options

Answer selected by manzanit0
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants