Skip to content
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

Add default display of chart alongside expectations #33

Conversation

MickeyKay
Copy link
Contributor

Addresses #32

This PR enables default display of the chart when expectations are present, and adds a new disableChart option that can be used to output expectation errors and warnings alone.

Copy link
Collaborator

@denar90 denar90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MickeyKay thanks. I left some comments. Can you also add some tests to that?

@@ -20,7 +20,6 @@ class PWMetrics {
constructor(url, opts) {
this.url = url;
this.opts = opts;
this.opts.disableCpuThrottling = this.opts.disableCpuThrottling || false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we should remove this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored. Accidentally removed this in my haste.

@@ -76,6 +75,9 @@ class PWMetrics {
if (this.opts.json) {
return data;
} else if (this.opts.expectations) {
if (!this.opts.disableChart) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using showChart option and make it true by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure - love it!

@@ -21,6 +21,7 @@ class PWMetrics {
this.url = url;
this.opts = opts;
this.opts.disableCpuThrottling = this.opts.disableCpuThrottling || false;
this.opts.showChart = (typeof this.opts.showChart !== 'undefined') ? (this.opts.showChart == 'true') : true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the best way to do this, however it seems that setting --showChart=false in CLI passes the showChart option through as a string instead of a bool. I thought about automatically parsing this in cli.js, however I think this warrants a different PR altogether if you'd like to go in that direction. This tidbit forces a boolean value no matter what. Would love to hear if you have a better suggestion on how to handle this more gracefully.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see 2 possible solutions here

  1. easy one like you did, just simplify a bit: this.opts.showChart = (this.opts.showChart === 'false') ? false : true;
  2. manage it on cli.js level - https://github.com/paulirish/pwmetrics/blob/master/bin/cli.js#L17
flags[flagKey] = keyValue[1] || true;
flags[flagKey] = (flags[flagKey] === 'false') ? false : flags[flagKey];

I'd prefer second one.

@MickeyKay
Copy link
Contributor Author

@denar90 Updated per your suggestions. I posed one question above and would love to hear your thoughts.

@@ -76,6 +77,9 @@ class PWMetrics {
if (this.opts.json) {
return data;
} else if (this.opts.expectations) {
if (this.opts.showChart) {
this.showChart(data);
}
expectations.checkExpectations(data.timings, this.opts.metrics)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one snit pick. @MickeyKay what do you think if we draw chart after expectations will be checked. Like

expectations.checkExpectations(data.timings, this.opts.metrics);
if (this.opts.showChart)  this.showChart(data);

Copy link
Contributor Author

@MickeyKay MickeyKay Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denar90 I actually prefer the existing arrangement, and here's why. Whenever I'm running any script, the final thing I always want to see in the output are errors/warnings. Reason being is that it's easier to lose track of said errors/warnings if they're earlier on in such output, and much less likely lost if they are the last piece of output.

Also, it seems to me like the logical order of things is 1. see timings 2. see errors/warnings resulting from these timings.

With that said, my preference would be to keep as is. Thoughts?

@paulirish
Copy link
Owner

what if we just always show the chart, even if we're running against expectations?

@MickeyKay
Copy link
Contributor Author

MickeyKay commented Jan 24, 2017

@paulirish this was my initial preference, hence the original (optional) disableChart option. That seems cleaner to me. Are you two okay with just outputting the chart no matter what?

@denar90
Copy link
Collaborator

denar90 commented Jan 24, 2017

@MickeyKay @paulirish SGTM.

@MickeyKay MickeyKay force-pushed the feature/allow-chart-display-with-expectations branch from 2f3ad8c to feb3ce6 Compare January 25, 2017 09:56
@denar90 denar90 merged commit 1a78359 into paulirish:master Jan 25, 2017
@MickeyKay
Copy link
Contributor Author

@denar90 @paulirish Okay, after all is said and done this PR is now super simple and simply outputs the chart regardless.

@denar90
Copy link
Collaborator

denar90 commented Jan 25, 2017

@MickeyKay thanks!

@MickeyKay
Copy link
Contributor Author

Oh wow. Merged already! Thanks 👍

@MickeyKay MickeyKay deleted the feature/allow-chart-display-with-expectations branch January 25, 2017 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants