Giter Club home page Giter Club logo

cprofile's Introduction

cprofile

Tool to gather useful information about a Go program

Problem

Would like to understand the composition of a partial or complete Go program (library or executable) via AST exporation.

Would like to be able to easily observe performance of Golang programs, sorting and filtering to discover hotspots, with a cross-platform interactive GUI.

Tools

This program exposes several tools

Globals

Using the globals command, one can discover whether there are any instances of global variables in the code.

cprofile globals main

Imports

The imports command will list the imported packages. See the complete documentation.

Building

go build -o bin/cprofile main/main.go

Vendoring

Use the dep tool for vendoring.

dep ensure

cprofile's People

Contributors

object88 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

cprofile's Issues

Share code among loader commands

The configuraions for loader commands is highly dupicated. Use common type for each and allow specifying or overriding uncommon parts.

Allow depth control for building ASTs

The globals and imports commands traverse the entire AST tree, which may not be what the user is interested in. For example, the user may not care what the stdlib imports.

Suggested traversal levels:

  • shallow - just the specified package
  • local - just packages that have the same root (i.e., github.com/object88)
  • deep - all non-stdlib packages
  • complete - every package, regardless of source

Might also be interesting to add a numeric depth control, stopping the traversal after N steps.

Verbose output crashes

Using the --verbose flag along with --astDepth c can sporadically cause the app to crash, presumably due to issues with package depth.

`imports` target must be have eponymous package name

This is a problem for main, which can be in any directory.

% ./bin/cprofile imports test/globals/main.go 

pkgName: 'github.com/object88/cprofile/test/globals/main.go'
Got error: Failed to locate package 'github.com/object88/cprofile/test/globals/main.go'

Respect vendored code

When showing list of imports, vendor packages show up as a vendored path, instead of their natural package names:

Actual:

...
flag
fmt
github.com/object88/cprofile
github.com/object88/cprofile/cmd
github.com/object88/cprofile/main
github.com/object88/cprofile/vendor/github.com/spf13/cobra
github.com/object88/cprofile/vendor/github.com/spf13/pflag
go/ast
go/build
...

Expected:

...
lag
fmt
github.com/object88/cprofile
github.com/object88/cprofile/cmd
github.com/object88/cprofile/main
github.com/spf13/cobra
github.com/spf13/pflag
go/ast
go/build
...

Support workspace loading

The current code expects to follow imports from a particular package, but this is not in line with the needs of consuming a project workspace. For example, if a project is open in an IDE, the program entry point will not necessarily align the root of the workspace:
~/go/src/github.com/foo/myProject/main
vs
~/go/src/github.com/foo/myProject
If myProject is the root for cprofile, it will not ingest main if that is where func main lives, due to Go's circular package reference avoidance.

If this library is going to be useful in an IDE that doesn't implicitly understand the ideal package starting point.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.