-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from codeperfio/publish.update
Update bin name and references
- Loading branch information
Showing
6 changed files
with
207 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# pprof-exporter | ||
Export and persist Go profiling data locally, or into https://codeperf.io for FREE. | ||
# codeperf | ||
Export and persist performance data into https://codeperf.io. | ||
|
||
|
||
bash <(curl -s https://raw.githubusercontent.com/codeperfio/pprof-exporter/main/get.sh) | ||
sudo install pprof-exporter /usr/local/bin/ | ||
bash <(curl -s https://raw.githubusercontent.com/codeperfio/codeperf/main/get.sh) | ||
sudo install codeperf /usr/local/bin/ | ||
|
||
pprof-exporter --help | ||
codeperf --help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package cmd | ||
|
||
import ( | ||
"go/ast" | ||
"go/parser" | ||
"go/token" | ||
"io/fs" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
func funcNames(filename string, exportOnly bool) []string { | ||
fset := token.NewFileSet() | ||
file, _ := parser.ParseFile(fset, filename, nil, 0) | ||
if exportOnly { | ||
ast.FileExports(file) // trim AST | ||
} | ||
|
||
funcNames := []string{} | ||
for _, decl := range file.Decls { | ||
fn, ok := decl.(*ast.FuncDecl) // assert type of declaration | ||
if !ok { | ||
continue | ||
} | ||
funcNames = append(funcNames, fn.Name.Name) | ||
} | ||
return funcNames | ||
} | ||
|
||
func GetBenchmarks(root string) ([]string, error) { | ||
var data []string | ||
fileSystem := os.DirFS(root) | ||
err := fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error { | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if filepath.Ext(path) != ".go" { | ||
return nil | ||
} | ||
if !strings.HasSuffix(filepath.Base(path), "_test.go") { | ||
return nil | ||
} | ||
fnames := funcNames(path, false) | ||
for _, fname := range fnames { | ||
if strings.HasPrefix(fname, "Benchmark") { | ||
data = append(data, fname) | ||
} | ||
} | ||
return nil | ||
}) | ||
return data, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters