Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Improve performance of generation #396

Closed
plakhotnii opened this issue Feb 17, 2020 · 1 comment · Fixed by #397
Closed

Improve performance of generation #396

plakhotnii opened this issue Feb 17, 2020 · 1 comment · Fixed by #397

Comments

@plakhotnii
Copy link
Contributor

After fixing problem with imports that includes the major version (#326) there are serious performance penalty.
To optimise process of getting correct packages names we can call go list command for all imports in file instead of calling it for each import independently.

Time consuming by mockgen:

Source mode

(v1.4.0)
time ../mockgen -source user.go -destination mock_user/mock_user.go Index,Embed,Embedded
../mockgen -source user.go -destination mock_user/mock_user.go   2.09s user 2.83s system 280% cpu 1.756 total
(with optimisations)
time ../mockgen -source user.go -destination mock_user/mock_user.go Index,Embed,Embedded
../mockgen -source user.go -destination mock_user/mock_user.go   0.54s user 0.63s system 320% cpu 0.364 total

Reflection mode

(v1.4.0)
time ../mockgen -destination mock_user/mock_user.go github.com/golang/mock/sample Index,Embed,Embedded
../mockgen -destination mock_user/mock_user.go  Index,Embed,Embedded  1.73s user 1.72s system 199% cpu 1.731 total
(with optimisations)
time ../mockgen -destination mock_user/mock_user.go github.com/golang/mock/sample Index,Embed,Embedded
../mockgen -destination mock_user/mock_user.go github.com/golang/mock/sample  0.96s user 0.53s system 153% cpu 0.972 total

In this example with sample package performance did not dramatically changed, but with packages that has many imports it did. For example, in my project generation time for some packages may take tens of seconds vs a few seconds or even under second with optimisation.

@codyoss
Copy link
Member

codyoss commented Feb 18, 2020

Thanks for the feedback, I will look at the PR sometime soon :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants