-
Notifications
You must be signed in to change notification settings - Fork 642
Add initial flamegraph web interface test. #802
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #802 +/- ##
=======================================
Coverage 66.99% 66.99%
=======================================
Files 45 45
Lines 9861 9861
=======================================
Hits 6606 6606
Misses 2795 2795
Partials 460 460 |
| setContext(name, ...args) { | ||
| let str = name + "("; | ||
| let sep = ""; | ||
| for (const arg of args) { |
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.
Can we use args.join(",")?
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.
Good idea. Done.
| } | ||
|
|
||
| log(...args) { | ||
| this.result.push(this.toArray("LOG", this.context, ...args)); |
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.
I don't know JS that well, but poking around a bit I think this can be just this.result.push("LOG", this.context, ...args);.
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.
Thanks. You were close. I needed:
this.result.push(["LOG", this.context, ...args]);
| @@ -0,0 +1,86 @@ | |||
| (function () { | |||
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.
nit: I would maybe give the function a name and then call it explicitly at the end. This syntax with parens gave me a bit of a pause when reading the code.
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.
Done.
| test.err("not above"); | ||
| } | ||
| // TODO: Allow checking boxes above pivots. | ||
| if (rb.left < ra.left || rb.right > rb.right) { |
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.
rb.right comparison should be rb.right > ra.right?
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.
Good catch. Fixed.
| } | ||
| // TODO: Allow checking boxes above pivots. | ||
| if (rb.left < ra.left || rb.right > rb.right) { | ||
| test.err("horizontal span is not nested inside horizontal span of"); |
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.
The "inside horizontal span of" part reads unfinished. Or maybe I misread it.
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.
Improved.
| // rect gets the bounding box for box with text t. | ||
| function rect(t) { | ||
| const elem = boxMap.get(t); | ||
| if (!elem) test.err("did not find", t); |
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.
Should we return here? Otherwise it seems we'd be dereferencing a null in the call in the next line.
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.
Done.
ghemawat
left a comment
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.
Thanks. Suggested changes made.
| setContext(name, ...args) { | ||
| let str = name + "("; | ||
| let sep = ""; | ||
| for (const arg of args) { |
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.
Good idea. Done.
| } | ||
|
|
||
| log(...args) { | ||
| this.result.push(this.toArray("LOG", this.context, ...args)); |
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.
Thanks. You were close. I needed:
this.result.push(["LOG", this.context, ...args]);
| @@ -0,0 +1,86 @@ | |||
| (function () { | |||
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.
Done.
| // rect gets the bounding box for box with text t. | ||
| function rect(t) { | ||
| const elem = boxMap.get(t); | ||
| if (!elem) test.err("did not find", t); |
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.
Done.
| test.err("not above"); | ||
| } | ||
| // TODO: Allow checking boxes above pivots. | ||
| if (rb.left < ra.left || rb.right > rb.right) { |
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.
Good catch. Fixed.
| } | ||
| // TODO: Allow checking boxes above pivots. | ||
| if (rb.left < ra.left || rb.right > rb.right) { | ||
| test.err("horizontal span is not nested inside horizontal span of"); |
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.
Improved.
We now do some rudimentary testing of the flamegraph web interface. The test code is written in Javascript and uses a simple test fixture class.
|
Cleaned up branch history by moving all changes made here into a single commit at the end. |
| test.setContext("checkWidth", t, fraction); | ||
| const r = rect(t); | ||
| if (!r) return; | ||
| const expect = (chartRect.width - 4) * fraction; |
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.
nit: a named constant for the 4 might be good, it's a bit obscure as is.
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.
That's a good point. Done, and thanks.
Question: I added the change as a separate commit. Do you prefer I amend the previous commit instead during code review and force push to github, or will you squash when you merge into main?
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.
My 2 cents: personally I think amending the commit is better than squashing it into one, because it would be easier to relate the comments and CI runs to code in the PR.
We will squash them when merging into main.
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.
I think you meant "adding a new commit" instead of "amending the commit"?
I agree with the decision to not squash until merging into main. Also makes it easier for reviewers to see the changes since the last round of reviews.
Thanks.
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.
Right, I think "adding a new commit" is better than "amending" (in between reviews), and is much better than "squashing" all previous commits into one.
Thanks!
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.
I don't have strong preference, separate commits are easier so probably the default choice. One added advantage is being able to move out a specific part of the change into a separate PR if requested by a reviewer - easier to do if it's a separate commit. Doesn't happen that often though, at least for this repo.
Louis-Ye
left a comment
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.
LGTM
We now do some rudimentary testing of the flamegraph web interface. The test code is written in Javascript and uses a simple test fixture class.