remyoudompheng / go-misc

Miscellaneous Go toys
Other
134 stars 24 forks source link

deadcode: Optimize use of loader package #11

Closed aaronbee closed 7 years ago

aaronbee commented 7 years ago

After the change to deadcode to use golang.org/x/tools/go/loader in 01514f0 the performance severly suffered. The runtime went from 0.5s to over 2min on a codebase that I work on. I believe this was caused by a bad use of the loader package.

I changed the code to import all packages at one time and only call Load() once. This got the runtime of deadcode back to where it was.

remyoudompheng commented 7 years ago

Hello, I had a local change doing already the same, which I had not pushed. In particular, it is not correct to test that arguments are directories. I am going to push mine and let you see if it's ok to you.

aaronbee commented 7 years ago

LGTM. Thanks!