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

Improve performance of generation #396

@plakhotnii

Description

@plakhotnii

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions