|
@@ -28,9 +28,10 @@ import (
|
28
|
28
|
)
|
29
|
29
|
|
30
|
30
|
var (
|
31
|
|
- javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
|
32
|
|
- goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
|
33
|
|
- cppRegExp = regexp.MustCompile(`^(?:(?:\(anonymous namespace\)::)(\w+$))|(?:(?:\(anonymous namespace\)::)?(?:[_a-zA-Z]\w*\::|)*(_*[A-Z]\w*::~?[_a-zA-Z]\w*))`)
|
|
31
|
+ javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
|
|
32
|
+ goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
|
|
33
|
+ cppRegExp = regexp.MustCompile(`^(?:[_a-zA-Z]\w*::)+(_*[A-Z]\w*::~?[_a-zA-Z]\w*)`)
|
|
34
|
+ cppAnonymousPrefixRegExp = regexp.MustCompile(`^\(anonymous namespace\)::`)
|
34
|
35
|
)
|
35
|
36
|
|
36
|
37
|
// Graph summarizes a performance profile into a format that is
|
|
@@ -429,6 +430,7 @@ func newTree(prof *profile.Profile, o *Options) (g *Graph) {
|
429
|
430
|
|
430
|
431
|
// ShortenFunctionName returns a shortened version of a function's name.
|
431
|
432
|
func ShortenFunctionName(f string) string {
|
|
433
|
+ f = cppAnonymousPrefixRegExp.ReplaceAllString(f, "")
|
432
|
434
|
for _, re := range []*regexp.Regexp{goRegExp, javaRegExp, cppRegExp} {
|
433
|
435
|
if matches := re.FindStringSubmatch(f); len(matches) >= 2 {
|
434
|
436
|
return strings.Join(matches[1:], "")
|