-
Notifications
You must be signed in to change notification settings - Fork 94
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
Conversation
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.
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
Outdated
end | ||
end | ||
|
||
def set_reporter(quiet:) |
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.
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
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.
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.
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 the answer is to have a public reporter=
method that self.quiet
calls and eventually we can deprecate it? thoughts on that?
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 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.
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 for the review @kbrock !
lib/benchmark/ips/job.rb
Outdated
end | ||
end | ||
|
||
def set_reporter(quiet:) |
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.
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.
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.
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.
lib/benchmark/ips/job.rb
Outdated
end | ||
end | ||
|
||
def set_reporter(quiet:) |
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 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.
hey @allcentury do you know how to rebase and squash some of your commits together? |
Hey @allcentury - do you have more to add here or are you waiting on my input? |
@kbrock - yes, I follow the @nateberkopec - thanks! Ya, could use your input: option A:
option B:
Initially I thought
Can you think of a good reason to have users inject their own |
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. |
Well, I don't have any desire to get rid of |
@nateberkopec - thanks for that. I think this is ready for your review then. |
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 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)
lib/benchmark/ips/job.rb
Outdated
@suite = suite || Benchmark::IPS::NoopSuite.new | ||
end | ||
|
||
def set_reporter(quiet:) |
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 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
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.
@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.
lib/benchmark/ips/job.rb
Outdated
@suite = suite || Benchmark::IPS::NoopSuite.new | ||
end | ||
|
||
def set_reporter(quiet:) |
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.
@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.
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.
@nateberkopec perfect, thank you! I removed the |
Thank you @allcentury |
thank you @allcentury |
This aims to close #112.
I removed references to
Benchmark::Suite
- I couldn't find anywherethis 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
All config gets passed into
job.config job_opts
and now the block isevaluated last allowing overrides.