-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support different display granularities in flame graph view. #896
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,29 @@ func TestShortNames(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestFileNameSuffixes(t *testing.T) { | ||
type testCase struct { | ||
name string | ||
in string | ||
out []string | ||
} | ||
test := func(name, in string, out ...string) testCase { | ||
return testCase{name, in, out} | ||
} | ||
|
||
for _, c := range []testCase{ | ||
test("empty", "", "."), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is "." expected here? I'm worried a little we'll show this dot in the UI when the profile does not have filenames (e.g. binary had symbols but no debug info). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is an artifact of the implementation leaking through. I can fix this in a subsequent change. Any suggestions for a better thing to display. Maybe "?" if neither func/file is available? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At a minimum I'd probably just leave it empty for now. I.e. just not turn empty strings into the dot. For the "?" - maybe, not sure, would need to look at it first. I believe we also use "unknown" and "" placeholders in some places, if we'd want to start using "?" I think three different ones might be too many :) |
||
test("simple", "foo", "foo"), | ||
test("manypaths", "a/b/c", "a/b/c", "b/c", "c"), | ||
test("leading", "/a/b", "/a/b", "a/b", "b"), | ||
test("trailing", "a/b", "a/b", "b"), | ||
} { | ||
t.Run(c.name, func(t *testing.T) { | ||
got := fileNameSuffixes(c.in) | ||
if !reflect.DeepEqual(c.out, got) { | ||
t.Errorf("fileNameSuffixes(%q) = %#v, expecting %#v", c.in, got, c.out) | ||
} | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One potentially unintended consequence of this change is that the default is now unclear in the output of the "o" command in the interactive shell.
Before:
With the change:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is reasonable given that the change proposes having different default granularities for different views.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we should at least show a string like "default" here? Showing empty string just looks a bit odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now show: