@@ -29,6 +29,7 @@ import (
2929 "path/filepath"
3030 "regexp"
3131 "strings"
32+ "time"
3233
3334 "github.com/cloudwego/abcoder/lang/log"
3435 . "github.com/cloudwego/abcoder/lang/uniast"
@@ -284,6 +285,10 @@ func getDeps(dir string, workDirs map[string]bool) (a map[string]string, cgoPkgs
284285
285286// ParseRepo parse the entiry repo from homePageDir recursively until end
286287func (p * GoParser ) ParseRepo () (Repository , error ) {
288+ start := time .Now ()
289+ defer func () {
290+ fmt .Fprintf (os .Stderr , "ParseRepo took %v\n " , time .Since (start ))
291+ }()
287292 for _ , lib := range p .modules {
288293 if strings .Contains (lib .path , "@" ) {
289294 continue
@@ -300,6 +305,10 @@ func (p *GoParser) ParseRepo() (Repository, error) {
300305}
301306
302307func (p * GoParser ) ParseModule (mod * Module , dir string ) (err error ) {
308+ start := time .Now ()
309+ defer func () {
310+ fmt .Fprintf (os .Stderr , "ParseModule %s took %v\n " , mod .Name , time .Since (start ))
311+ }()
303312 // run go mod tidy before parse
304313 cmd := exec .Command ("go" , "mod" , "tidy" )
305314 cmd .Dir = dir
@@ -333,6 +342,7 @@ func (p *GoParser) ParseModule(mod *Module, dir string) (err error) {
333342
334343 if p .opts .LoadByPackages {
335344 var errs []error
345+ startWalk := time .Now ()
336346 filepath .Walk (dir , func (path string , info fs.FileInfo , e error ) error {
337347 if e != nil || ! info .IsDir () || shouldIgnoreDir (path ) {
338348 return nil
@@ -347,6 +357,7 @@ func (p *GoParser) ParseModule(mod *Module, dir string) (err error) {
347357 }
348358 return nil
349359 })
360+ fmt .Fprintf (os .Stderr , "ParseModule Walk %s took %v\n " , mod .Name , time .Since (startWalk ))
350361 if len (errs ) > 0 {
351362 return fmt .Errorf ("parse package failed: %v" , errs )
352363 }
0 commit comments