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

Allow Suite To be Set via Accessor #113

Merged
merged 1 commit into from
Apr 5, 2021

Conversation

allcentury
Copy link

This aims to close #112.

I removed references to Benchmark::Suite - I couldn't find anywhere
this was used and the original commit goes back a long ways. This looks
like a relic to a class or module that I'm not able to find in git
history via

git grep 'Suite' $(git rev-list --all)

All config gets passed into job.config job_opts and now the block is
evaluated last allowing overrides.

@allcentury allcentury mentioned this pull request Mar 17, 2021
Copy link
Contributor

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

this looks nice.

not a fan of the set_reporter method but the removal of the if statements sure makes this nicer.

lib/benchmark/ips/job.rb Show resolved Hide resolved
lib/benchmark/ips/job.rb Outdated Show resolved Hide resolved
lib/benchmark/ips/job.rb Show resolved Hide resolved
end
end

def set_reporter(quiet:)
Copy link
Contributor

Choose a reason for hiding this comment

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

since this only accepts quiet, does it make sense to just move the contents of this over to def quiet=

or do you have plans on allowing a report to be passed into here in the future?
If you wanted that, you could do quiet=true or reporter=NoopReport.new

Copy link
Author

Choose a reason for hiding this comment

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

Great points. I was thinking reporter should eventually use dependency injection and if no report is passed in then we'll default to Noop. Then, we can actually decommission quiet from the public API and instead, if you don't want output you pass in the NoopReport. I think the idea of a reporter and quiet are conflating the same thing but getting rid of quiet seemed like a breaking change at this time.

Copy link
Author

Choose a reason for hiding this comment

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

Maybe the answer is to have a public reporter= method that self.quiet calls and eventually we can deprecate it? thoughts on that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that idea a lot. it is consistent with your current approach and the approach this project seems to be headed.
At one time, quiet made sense. But now that people want more control over capturing the output, introducing a reporter accessor sounds good.

lib/benchmark/ips/job.rb Show resolved Hide resolved
@kbrock kbrock mentioned this pull request Mar 19, 2021
Copy link
Author

@allcentury allcentury left a comment

Choose a reason for hiding this comment

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

Thanks for the review @kbrock !

lib/benchmark/ips/job.rb Show resolved Hide resolved
lib/benchmark/ips/job.rb Show resolved Hide resolved
lib/benchmark/ips/job.rb Outdated Show resolved Hide resolved
end
end

def set_reporter(quiet:)
Copy link
Author

Choose a reason for hiding this comment

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

Great points. I was thinking reporter should eventually use dependency injection and if no report is passed in then we'll default to Noop. Then, we can actually decommission quiet from the public API and instead, if you don't want output you pass in the NoopReport. I think the idea of a reporter and quiet are conflating the same thing but getting rid of quiet seemed like a breaking change at this time.

Copy link
Contributor

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

This is looking nice.
I like where you are going with reporter=

But please note, that while I have contributed a few PRs here, I am not the maintainer so take my words with a grain of salt.

I have put in a few PRs around better capturing the output, that is why I'm vocal here. A number of people have expressed the desire to have better output / hence another pr that I have open. this seems to overlap that one a bit - so keep it coming and I'll refactor that one.

end
end

def set_reporter(quiet:)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that idea a lot. it is consistent with your current approach and the approach this project seems to be headed.
At one time, quiet made sense. But now that people want more control over capturing the output, introducing a reporter accessor sounds good.

lib/benchmark/ips/job.rb Show resolved Hide resolved
@kbrock
Copy link
Contributor

kbrock commented Mar 30, 2021

hey @allcentury do you know how to rebase and squash some of your commits together?
It makes for a cleaner git history in the future. (the changes now are the history in the future... Marty McFly would be proud)

@nateberkopec
Copy link
Collaborator

Hey @allcentury - do you have more to add here or are you waiting on my input?

@allcentury
Copy link
Author

allcentury commented Mar 31, 2021

@kbrock - yes, I follow the fixup flow until it's ready to merge, then I squash.

@nateberkopec - thanks! Ya, could use your input:

option A:

  1. deprecate quiet in favor of setting a reporter.
  2. If you want no output, use the NoopReporter.
  3. Replace docs on quiet with NoopReporter
  4. Eventually let anyone inject their own Reporter as long as it conforms to the interface
  5. Do we merge format + reporter? CsvReporter, JsonReporter, etc.

option B:

  1. Keep quiet and don't surface the reporter idea
  2. Nothing to deprecate/change
  3. Don't merge format config with the output config

Initially I thought reporter could allow users to write their own formatters like csv, json, etc. However I see there is a format option. As it stands w/ this PR:

StdoutReport:

  1. Sends everything to stdout

NoopReport:

  1. No output

:format

  1. Raw or Human, used by the Report classes above.

Can you think of a good reason to have users inject their own Report class? I can't without conflating format. So I'm leaning towards Option B now. Thoughts?

@kbrock
Copy link
Contributor

kbrock commented Apr 1, 2021

Can you think of a good reason to have users inject their own Report class? I can't without conflating format. So I'm leaning towards Option B now. Thoughts?

There was a request #81 to be able to capture the output. So as long as you could set a string output buffer or something, then that would move this gem towards solving that issue. I had started on a PR to solve that issue but I like where this PR is going and can fix the other PR after you are done here.

@nateberkopec
Copy link
Collaborator

Well, I don't have any desire to get rid of quiet. I think setting quiet should just silently swap out the reporter in the background. So I guess that makes me option B? I don't think the other decisions/points in the PR need to be solved today, maybe we merge reporters/formatters in the future but I don't think that has to be solved now.

@allcentury
Copy link
Author

@nateberkopec - thanks for that. I think this is ready for your review then.

Copy link
Contributor

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

I like all but that one method.
since it is only used in the one spot, this seems a simple change

but obviously, I defer to nick on this all (since he is supporting the gem after all)

@suite = suite || Benchmark::IPS::NoopSuite.new
end

def set_reporter(quiet:)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the only part that is suspect.

introducing report= is ok - or not. Just use that and set the value based upon quiet.
but the set_reporter doesn't seem right to me

Copy link
Collaborator

Choose a reason for hiding this comment

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

@allcentury Purely from a style perspective, get_ and set_ methods don't belong in Ruby for me. It looks like PHP or JS. I think this should just be reporter=. I have no problem with what the method does.

@suite = suite || Benchmark::IPS::NoopSuite.new
end

def set_reporter(quiet:)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@allcentury Purely from a style perspective, get_ and set_ methods don't belong in Ruby for me. It looks like PHP or JS. I think this should just be reporter=. I have no problem with what the method does.

@nateberkopec
Copy link
Collaborator

1 rename and it's GTG

This aims to close evanphx#112.

I removed references to `Benchmark::Suite` - I couldn't find anywhere
this was used and the original commit goes back a long ways.  This looks
like a relic to a class or module that I'm not able to find in git
history via

```
git grep 'Suite' $(git rev-list --all)
```

All config gets passed into `job.config job_opts` and now the block is
evaluated last allowing overrides.
@allcentury
Copy link
Author

@nateberkopec perfect, thank you! I removed the set and now reporter is a pure function which quiet= relies on.

@nateberkopec nateberkopec merged commit bc84a73 into evanphx:master Apr 5, 2021
@nateberkopec
Copy link
Collaborator

Thank you @allcentury

@kbrock
Copy link
Contributor

kbrock commented Apr 6, 2021

thank you @allcentury

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suite Only Availabe via config
3 participants